Reputation: 119
Use map with several arguments?
Something like foldr or foldl?
Upvotes: 1
Views: 730
Reputation: 1310
Haskell supports partial application, which means you can pass only a few arguments into a function, and you will get out a function which takes the rest of the arguments.
For example, I can take an expression like:
map (\x -> x*x) [1,2,3,4]
and rewrite it as:
let mapsquare = map (\x -> x*x) in mapsquare [1,2,3,4]
In the above case, I've taken the partially applied map, and assigning it to a variable, and then using that function of one argument on a list.
In your example, you could write let f = func str1 str2 in map f charls
, or map (func str1 str2) charls
.
Upvotes: 3
Reputation: 2790
If the other arguments are fixed, do a partial application. E.g.:
map (func arg1 arg2) your_list
Upvotes: 5