[英]Haskell : List of anonymous functions using lambda expressions
我对 Haskell 很陌生,我想使用 lambda 表达式定义一个匿名函数列表,它代表四种基本的算术运算。
this is what i have done bao = (\ x y -> x+y)
but i want to apply 3 more expressions(\x y ->x-y)
(\x y ->x*y)
(\x y ->x/y)
as well by putting bao before them just like what i have done to operation (+) ,and it shows error : multi declaration of 'bao' ,what can i do ?
Thank you in advance!
您必须定义一个列表。
bao = [\x y -> x + y, \x y -> x - y , \x y -> x * y, \x y -> x / y]
这将更简单地定义为
bao = [(+), (-), (*), (/)]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.