Closed atifaziz closed 9 years ago
(++)
?
[1 2 3] |> (++) [4 5 6]
→ [ 4, 5, 6, 1, 2, 3 ]
.
@anko Great suggestion (I have forgotten about ++
) and I can live with that for now. The only difference is that (and which I also forgot to specify in my original comment) it would behave more like:
[1 2 3] |> append [4 5 6] #=> [1, 2, 3, 4, 5, 6]
But I could partially apply ++
with a placeholder as follows to get that effect as part of a pipeline:
[1 2 3] |> ((++) _, [4 5 6])
That would make the definition of append
just a flip of ++
arguments:
append = (xs, ys) --> ys ++ xs
…boiling down to just:
append = flip (++)
If the prelude maintainers feel append
doesn't add any value (even for readability) then I wouldn't be completely annoyed or disappointed if this issue is closed. :smirk: Then again, not sure where you draw the with one-liner functions.
I think ++
is good enough.
[1 2 3] |> (++ [4 5 6])
#=> [1,2,3,4,5,6]
@gkz Okay, I clearly forgot the first of the two examples listed in the docs:
(+ 2) 4 #=> 6
(*) 4 3 #=> 12
It would've done the job in the first place. I don't know why I kept insisting on the second form; could be muscle memory from F# that requires the second form.
This:
would make writing the following possible:
Signature: [a] → [a] → [a]
Unless, of course, I've missed something in the LiveScript bag of tricks.