I want to know whether shift is a higher order function or not.
chartoInt :: Char -> Int
chartoInt c = ord c
Inttochar :: Int -> Char
Inttochar n = chr n
shift :: Int -> Char -> Char
shift n c = Inttochar (chartoInt c + n)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
None of these functions are higher order functions, because none of these functions take a function as a parameter.
shift‘s parameters aren(anInt) andc(aChar): neither are functions.(Also:
Inttocharshould beinttochar: function names in Haskell cannot start with an upper case letter.)Here’s a higher order function that looks like your
shift:Or, perhaps more usefully:
You can read the type signature for
anotherHigherShiftas saying thatIntand returns anInt)CharChar(+n)is shorthand for\m -> m + n.