3 ms·
This is more of a style thing than anything else. Nothing stopping you from writing Python in an idempotent and functional style. I do it all the time. def
by whalesalad 2y ago
This is more of a style thing than anything else. Nothing stopping you from writing Python in an idempotent and functional style. I do it all the time.
def winning_team(game_log: GameLog) -> Team:
team_a, team_b = get_teams(game_log)
points_a = get_points(game_log, team_a)
points_b = get_points(game_log, team_b)
return team_a if points_a > points_b else team_b
- IshKebab 2y agoWell the syntax certainly fights you the whole way...
- whalesalad 2y agoHow?
- IshKebab 2y agoThe entire language is statement based, not expression based. Lambda functions are limited to a single expression. Weird special snowflake syntax for if expressions and array comprehension. Etc.
- jasonjmcghee 2y agoI would argue the functional approach is (copying your data structures): def winning_team(game_log: GameLog) -> Team: return max( get_teams(game_log), key=lambda t: get_points(game_log, t) )
- whalesalad 2y agoI think this is a very unproductive and pedantic take of functional programming. Inside the function, all things being equal, the implementation isn’t important. The important thing is that it’s isolated, self contained and does not perform I/O
- zck 2y agoI think the point the author is making is: unless you control all the code you're calling, in a language without immutable datatypes, you can't be sure the other functions don't change your data.