Haskell confusion (81)

64 Name: #!/usr/bin/anonymous : 2006-04-06 01:34 ID:jLQEuxPf

>>63
Yes, I certainly do design with currying in mind. I don't see what's wrong with that. Having a convention for the order of arguments is a good thing in any language, and putting the more general arguments first is as useful a convention as any.

flip is useful in other situations besides currying. Are you familiar with foldl? It folds up a list using a binary operator and a start value: foldl op start [a,b,c] is equivalent to ((start op a) op b) op c. You can for example flip the : operator (which adds an element onto the start of a list) and reverse a list with reverse ls = foldl (flip (:)) [] ls.

Alternately, because of currying, you can just define that as reverse = foldl (flip (:)) []. This is called pointfree style and is considered cleaner than the other definition, since it's done at a higher level, dealing with functions rather than their arguments. I don't think you could do that as cleanly without currying.

Again, why currying, or any technique I use for that matter, was invented is not important to me. If it's useful, it's useful. Maybe you don't think it's useful and we can argue about that, but it still doesn't matter why it was invented.

This thread has been closed. You cannot post in this thread any longer.