简体   繁体   中英

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 ie 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?

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM