3 ms·
In the end it's a matter of taste, I find the second version much clearer
by EwanToo 14y ago
In the end it's a matter of taste, I find the second version much clearer
- simias 14y agoI think they are both caricatural. I don't write haskell but if I did I think I'd go with: map func (first:rest) = func first : map func rest Maybe using car and cdr for first and rest because of my lisp background. That being said, for such a simple function using f, x and xs is probably fine (the way using int i; in C is fine).
- nandemo 14y agoThe first version is pretty standard Haskell. Certainly not caricatural. For generic code, writing first:rest is not bad but it does look a bit superfluous, somewhat like writing quotient = numerator / denominator instead of simply x = y / z. It doesn't really give you any extra information, and for me it sort of suggests that the programmer needs to remind themselves of what the operators : and / mean. Of course, if the code is not generic and the variables do have concrete meanings you should name them appropriately, e.g. roi = return / investment. But when we write x:xs it's typically polymorphic (or otherwise generic) code.
- deleted 14y ago[deleted]