3 ms·
Thanks! Is this the case in Elm as well? This is the example they give: connectWords : String -> String -> String connectWords firstWord secondWord = f
by Kiro 10y ago
Thanks! Is this the case in Elm as well? This is the example they give:
connectWords : String -> String -> String
connectWords firstWord secondWord =
firstWord ++ secondWord
- elbenshira 10y agoIn this case, you think of `connectWords` as a function that takes two arguments. But since it is curried, you can also do this: let prefix = connectWords "Hello " world = prefix "world" bob = prefix "bob" in ... `world` is "Hello world", and `bob` is "Hello bob". That is the power of currying. A maybe more useful example is specifying the mapping function in `List.map` without supplying the list to map over. This allows you to use the same map with multiple lists.
- taylorfausak 10y agoYes, all functions in Elm also have arity 1. That example desugars into this: connectWords = \ firstWord -> \ secondWord -> firstWord ++ secondWord