3 ms·
$ (1..10) |> Enum.map(&(&1**&1)) |> Enum.filter(&(&1 < 40)) This is the equivalent of this piping op done in terse style JS: [for (i of Array(10).keys())
by gotchange 11y ago
$ (1..10) |> Enum.map(&(&1**&1)) |> Enum.filter(&(&1 < 40))
This is the equivalent of this piping op done in terse style JS:
[for (i of Array(10).keys()) ++i].map(e=> e*e ).filter(e=> e<40 )
This is not as concise as the example you provided but it's still very neat and powerful.
- oinksoft 11y agoAre list comprehensions still part of ES7? It's strange that Babel removed the list comprehension transformer recently, but I haven't been following closely. The Elixir pipe syntax is reminiscent of Clojure's ->/->>: (->> (range 1 10) (map #(* % %)) (filter (partial > 40))) It's nice that in languages like Haskell or ML this is trivial: infix |> fun (a |> b) = a b You could modify this to let NONE fall through, etc.