小编yes*_*sar的帖子

为什么这个功能是咖喱的?

根据我的理解,curried函数应该总是返回一个函数.但是,在下面的代码中,我相信这个函数返回一个列表.但是当我检查类型时,它看起来像一个curried函数.

fun zipWith f xs ys =
    case (xs,ys) of
         ([],_) => []
      | (_,[]) => []
      | (x::xs',y::ys') => (f(x,y)) :: zipWith f xs' ys'
Run Code Online (Sandbox Code Playgroud)

类型:

val zipWith = fn : ('a * 'b -> 'c) -> 'a list -> 'b list -> 'c list.
Run Code Online (Sandbox Code Playgroud)

有人可以解释这个函数中的类型和currying的工作原理.任何帮助表示赞赏!

sml currying

0
推荐指数
1
解决办法
57
查看次数

标签 统计

currying ×1

sml ×1