1

Use map with several arguments?

Something like foldr or foldl?

2
  • 3
    map (func arg1 arg2) charList Commented Nov 20, 2017 at 18:10
  • 5
    Please show a sample input and the desired output. Commented Nov 20, 2017 at 19:08

2 Answers 2

5

If the other arguments are fixed, do a partial application. E.g.:

map (func arg1 arg2) your_list
Sign up to request clarification or add additional context in comments.

Comments

3

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.