3 ms·
I think this is the case that the choice of the syntax (and a bit of semantics) did affect the choice of API. I'm not a Python programmer, but I can see in you
by shiro 18y ago
I think this is the case that the choice of the syntax (and a bit of semantics) did affect the choice of API. I'm not a Python programmer, but I can see in your second example that they would prefer comprehensions to filter.
If there were curring or some convenient partial application syntax in the language, using 'filter' can be more natural choice. In Gauche Scheme, pa$ is a built-in partial applicaiton and I'd write:
(filter (pa$ string-suffix? ".py") (sys-readdir some-dir))
Or in Haskell:
getDirectoryContents somedir >>= return . filter (isSuffixOf ".py")
In general I'd rather write this in Gauche, for a regexp object is applicable:
(filter #/\.py$/ (sys-readdir some-dir))
So, if you have more variations than the bare lambda to create a higher order function (either in currying, partial application, or promoting objects to applicable something, etc), the more the functions such as filter, fold etc become useful. If you need to fall back to lambda for most of times, it would be natural that using those fns becomes annoying.