Remix.run Logo
▲ stingraycharles 37 minutes ago

Not really, what Haskell / Erlang offer is that you can do pattern matching in the function signature.

So you can, say, have a definition for when the value of n is 0, n is 1, etc.

This is a nice example in Haskell:

   compress :: Eq a => [a] -> [a]
   compress [] = []
   compress [x] = [x]
   compress (x:ys@(y:_))
     | x == y    = compress ys
     | otherwise = x : compress ys
Basically it enables you to use recursion more elegantly.