不应该像Haskell这样的惰性语言允许这个定义,其中函数是curry?
apply f [] = f
apply f (x:xs) = apply (f x) xs
Run Code Online (Sandbox Code Playgroud)
它基本上是一个将给定函数应用于给定参数列表的函数,并且很容易在Lisp中完成.有没有解决方法?
我想知道是否可以从 Haskell 中的可迭代事物中创建变量。我在搜索时发现了这个,但我无法适应我的情况。也许这是不可能的,或者我错过了一些东西,因为我是初学者。基本上,我想知道在 Haskell 中是否有可能发生这样的事情:
>>> list_of_lists = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
>>> a, b, c = list_of_lists
>>> print(a)
[1, 2, 3]
Run Code Online (Sandbox Code Playgroud)