Re: Vectorized functions

2016-08-10 Thread Christian Gollwitzer
Am 11.08.16 um 06:02 schrieb Steven D'Aprano: Here's a neat little decorator which decorates a function with a special callable attribute "v" which operates somewhat like Julia's dot syntax: def vectorize(func): def v(seq, **kw): return [func(x, **kw) for x in seq] func.v = v

Re: Vectorized functions

2016-08-10 Thread Paul Rubin
Steven D'Aprano writes: > Is there any other functionality which would make this more useful? Cute, but map or listcomps work ok. Here's the Haskell equivalent to your example, fwiw, using the <$> operator from the Control.Applicative module: (+2) <$> [1,2,3] => [3,4,5] If you haven't trie