4 ms·
I 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
by simias 14y ago
I 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]