Prelude -- passing the function as the last argument rather than the first

29 views
Skip to first unread message

Joshua Kifer

unread,
Jul 29, 2013, 1:16:35 PM7/29/13
to lives...@googlegroups.com
I feel like I have seen a discussion on this elsewhere, so if anyone remembers, just point me there.

When using the prelude functions, they all take the function argument as the first one.  I feel it would be better style to have the function as the final argument, as they may contain a long block.  So my question is, are there any techniques or project to publish prelude.js where the functions arguments have been modified in this manner?

Thanks.

George Zahariev

unread,
Jul 29, 2013, 2:10:23 PM7/29/13
to lives...@googlegroups.com
The function is first because the prelude functions are curried.
This allows you to do:

list |> filter even |> map (+ 2) |> etc

This is perfectly valid code:

[1 to 5] 
|> map (x) ->
    x * x
|> filter (x) ->
    n = 2
    x % n == 0
Reply all
Reply to author
Forward
0 new messages