{1574} revision 2 modified: 10-11-2022 21:36 gmt |

https://stackoverflow.com/questions/26475765/ocaml-function-with-variable-number-of-arguments From this I learned that in ocaml you can return not just functions (e.g. currying) but let sum f = f 0 ;; let arg a b c = c ( b + a ) ;; let z a = a ;; then sum (arg 1) ;; is well-typed as (int -> `a) -> `a = <fun> e.g. an sum (arg 1) (arg 2);; can be parsed as (sum (arg 1)) (arg 2) ;; '(arg 2)' outputs an application of an int & a yet-to 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 yet-to-be 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. |