Hacker News new | ask | show | jobs
by bigdubs 4441 days ago
so what this is getting at more is that lambdas are a critical part of a language; the "genericness" they provide keeps you from having to write a sort method for each of your types.

instead of three separate functions for len, swap and less, you'd just have one function

collection.sort(a => a.foo)

the swap and len functions are part of the collection type. the less function would be part of an interface on whatever type foo is.

it's not so much about api verbosity as not having to write the same functions over and over.

it's possible from a pure performance perspective that setting up the closures is bad but it's something i'd be willing to take for that much less code to write.