Re: [Haskell-cafe] Newbie syntax question

map (foo 5) my_list_of_lists_of_doubles
1. map (flip foo 5) my_list_of_lists_of_doubles 2. map (`foo` 5) my_list_of_lists_of_doubles 3. map (\x->foo x 5) my_list_of_lists_of_doubles 4. [foo x 5 | x <- my_list_of_lists_of_doubles]
well, i've followed this discussion a while, but i did not see that solution i used for years. (i like solution 2, never thought of it before.) my solution is a variant of 1, that makes the reading a little bit easier -- at least to me. 5. map (foo `flip` 5) my_list_of_lists_of_doubles the `flip` shows the position behind foo, where to put the parameter. its a pitty that it only works if there is only one parameter behind `flip`. so, with abcd :: a->b->c->d->x abcd a b `flip` d :: c->x works, but abcd a `flip` c d :: b->x does not. experimenting with Data.Arrow, it could look like: (abcd a >>> ($ c) >>> ($ d)) :: b->x or with a flip-arrow combination: (abcd a `flip` c) >>> ($ d) :: b->x so, instead of hacking with arrows on it, i prefer solutions 3 and 4 whenever 5 does not work. - marc

1. map (flip foo 5) my_list_of_lists_of_doubles 2. map (`foo` 5) my_list_of_lists_of_doubles 3. map (\x->foo x 5) my_list_of_lists_of_doubles 4. [foo x 5 | x <- my_list_of_lists_of_doubles]
5. map (foo `flip` 5) my_list_of_lists_of_doubles
Thank you all, for your answers. This nice discussion made even more clear to me how powerful Haskell is. Cheers, André
participants (2)
-
André Vargas Abs da Cruz
-
Marc Ziegert