我在使用函数来删除Haskell中的三个参数时遇到了麻烦.
免责声明:不是课程作业,今天有人在挣扎着问我这个问题,这一直困扰着我.
我们给出的自定义类型/函数是(只能记住类型)
type MyThing
= (Char, String)
type MyThings
= [MyThing]
funcA :: MyThings -> String -> String
funcB :: MyThings -> String -> Int -> String
Run Code Online (Sandbox Code Playgroud)
我们开始:
funcB as str n = iterate (funcA as) str !! n
Run Code Online (Sandbox Code Playgroud)
并将其减少如下:
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
Run Code Online (Sandbox Code Playgroud)
然后,卡住了.我们无法弄清楚如何避免使用最后一个参数.我知道我以前见过类似的情况并且有一个解决方案. …