Curried anonymous function in SML

前端 未结 3 610
Happy的楠姐
Happy的楠姐 2021-02-07 02:55

I have the function below and it works:

(fn x => x * 2) 2; 

but this one doesn\'t work:

(fn x y => x + y ) 2 3;
         


        
3条回答
  •  Happy的楠姐
    2021-02-07 03:21

    In Standard ML, a function can have only one argument, so use

    (fn (x,y) => x + y) (2,3) 
    

    and the type is

    fn: int * int -> int
    

    in this time (x,y) and (2,3) is a list structure,

提交回复
热议问题