-2

i am quite new to Haskell and i want to define a list of anonymous functions using lambda expressions, which represent the four basic arithmetic operations.

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!
                          
John
  • 135
  • 6

1 Answers1

2

You have to define a list.

bao = [\x y -> x + y, \x y -> x - y , \x y -> x * y, \x y -> x / y]

which would be more simply defined as

bao = [(+), (-), (*), (/)]
chepner
  • 497,756
  • 71
  • 530
  • 681