I'm having trouble with currying a function to remove three arguments in Haskell.
Disclaimer: Not Coursework, I was asked this question by someone struggling with this today and it's been bugging me.
The custom types/functions we were given were (can only remember types)
type MyThing
= (Char, String)
type MyThings
= [MyThing]
funcA :: MyThings -> String -> String
funcB :: MyThings -> String -> Int -> String
We started with:
funcB as str n = iterate (funcA as) str !! n
And reduced it down as follows:
funcB as str n = iterate (funcA as) str !! n
funcB as str = (!!) . (iterate (funcA as)) str
funcB as = (!!) . (iterate (funcA as))
funcB as = (!!) . (iterate . funcA) as
Then, stuck. We just can't figure out how to avoid using the last argument. I know I've seen a similar situation somewhere before and there was a solution.
Hoping some Haskell genius can point out why I'm being an idiot...
pointfree
to do this automatically. – Etherize