相关疑难解决方法(0)

什么是'Currying'?

我在几篇文章和博客中看到了对curried函数的引用,但我找不到一个好的解释(或者至少有一个有意义的解释!)

functional-programming terminology definition currying

628
推荐指数
12
解决办法
15万
查看次数

Haskell printf如何工作?

Haskell的类型安全性仅对于依赖类型的语言是首屈一指的.但是Text.Printf有一些深刻的魔力似乎相当类型.

> printf "%d\n" 3
3
> printf "%s %f %d" "foo" 3.3 3
foo 3.3 3
Run Code Online (Sandbox Code Playgroud)

这背后的深层魔力是什么?该Text.Printf.printf函数如何采用像这样的可变参数?

用于允许Haskell中的可变参数的一般技术是什么,它是如何工作的?

(旁注:使用这​​种技术时,某种类型的安全性显然会丢失.)

> :t printf "%d\n" "foo"
printf "%d\n" "foo" :: (PrintfType ([Char] -> t)) => t
Run Code Online (Sandbox Code Playgroud)

printf haskell variadic-functions polyvariadic

99
推荐指数
1
解决办法
1万
查看次数

如何在Haskell中压缩多个列表?

在python zip函数中接受任意数量的列表并将它们拉到一起.

>>> l1 = [1,2,3]
>>> l2 = [5,6,7]
>>> l3 = [7,4,8]
>>> zip(l1,l2,l3)
[(1, 5, 7), (2, 6, 4), (3, 7, 8)]
>>> 
Run Code Online (Sandbox Code Playgroud)

我如何zip在haskell中组合多个列表?

haskell list

16
推荐指数
4
解决办法
1万
查看次数

如何在Haskell中实现通用的"zipn"和"unzipn"?

我在基本的Haskell库中找到了这个文档:

zip :: [a] -> [b] -> [(a, b)]
    zip takes two lists and returns a list of corresponding pairs. If one input list is short, excess elements of the longer list are discarded.

zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]
    zip3 takes three lists and returns a list of triples, analogous to zip.

zip4 :: [a] -> [b] -> [c] -> [d] -> [(a, b, c, d)]
    The zip4 function takes four lists and returns …
Run Code Online (Sandbox Code Playgroud)

haskell

4
推荐指数
1
解决办法
547
查看次数