Eddie
Eddie

Reputation: 891

Mapping 3 argument function to a list in Haskell

The map function works fine on really easy functions that take no arguments like *7 to every element in a list of Ints.

But say I made a custom function that takes a Char, String and Int and then returns a Char and I wanted to apply this function to a list of Chars i.e. a String to get a String back after applying the other function to each Char? When I try this all I get is error messages?

Upvotes: 0

Views: 1263

Answers (1)

nponeccop
nponeccop

Reputation: 13677

Put your Char argument to the last position:

foo :: String -> Int -> Char -> Char
foo str num c = c

bar = map (foo str num)

But we really need some more information from your side to help you better. Can you add the code you tried to write to your question?

Upvotes: 1

Related Questions