【发布时间】:2012-10-30 13:23:44
【问题描述】:
我在使用柯里化函数来删除 Haskell 中的三个参数时遇到问题。
免责声明:不是课程作业,今天有人向我提出了这个问题,这一直困扰着我。
我们得到的自定义类型/函数是(只能记住类型)
type MyThing
= (Char, String)
type MyThings
= [MyThing]
funcA :: MyThings -> String -> String
funcB :: MyThings -> String -> Int -> String
我们从:
funcB as str n = iterate (funcA as) str !! n
并将其减少如下:
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
然后,卡住了。我们只是不知道如何避免使用最后一个参数。我知道我以前在某处看到过类似的情况,并且有解决方案。
希望一些 Haskell 天才能指出我为什么是个白痴...
【问题讨论】:
-
您可以使用
pointfree自动执行此操作。 -
大呼,会调查的!