m8ta
You are not authenticated, login. 

{1574} 
ref: 0
tags: ocaml application functional programming
date: 10112022 21:36 gmt
revision:2
[1] [0] [head]


https://stackoverflow.com/questions/26475765/ocamlfunctionwithvariablenumberofarguments From this I learned that in ocaml you can return not just functions (e.g. currying) but appliations of yettobe named functions. let sum f = f 0 ;; let arg a b c = c ( b + a ) ;; let z a = a ;; then sum (arg 1) ;; is welltyped as (int > `a) > `a = <fun> e.g. an application of a function that converts int to `a. Think of it as the application of Xa to argument ( 0 + 1 ), where Xa is the argument (per type signature). Zero is supplied by the definition of 'sum'. sum (arg 1) (arg 2);; can be parsed as (sum (arg 1)) (arg 2) ;; '(arg 2)' outputs an application of an int & a yetto be determined function to 'a, E.g. it's typed as int > (int > `a) > `a = <fun>. So, you can call it Xa passed to above. Or, Xa = Xb( ( 0 + 1 ) + 2) where, again, Xb is a yettobe defined function that is supplied as an argument. Therefore, you can collapse the whole chain with the identity function z. But, of course, it could be anything else  square root perhaps for MSE? All very clever. 