News for hackers. Stuff that matters.
Re:JavaScript is Good, Actually by hueving on Wednesday May 16, 2018 @08:17AM (#17081756)
You pass functions just like any other argument.

clos = 42

def foo(x): return x + clos

def bar(y): return y * clos

higher_order(foo, bar)

What's so hard about that?

Re:JavaScript is Good, Actually by amelius on Wednesday May 16, 2018 @09:05AM (#17082031)
Here's a challenge: try inlining the foo and bar in the call (because this is how functions are typically composed in functional programming)

You could do this with a lambda construct in Python; but this only works if the function has a single expression-statement; it doesn't work e.g. when you have a bunch of assignments inside the function you are inlining.

Re:JavaScript is Good, Actually by hueving on Thursday May 17, 2018 @04:05PM (#17095072)
>Here's a challenge: try inlining the foo and bar in the call (because this is how functions are typically composed in functional programming)

Sure, it's ugly but I think it's a silly challenge. Complex functions defined in the function call are un-maintainable anyway IMO.