microsoft / knossos-ksc

Compiler with automatic differentiation
Other
45 stars 10 forks source link

Add a function to convert Defs to one-arg #901

Closed acl33 closed 3 years ago

acl33 commented 3 years ago

E.g. (def foo Float ((a : Float) (b : Float)) (mul (add a 2.0) (add b 3.0))) becomes:

(def foo Float (func_arg_0 : Tuple Float Float)
    (let (a (get$1$2 func_arg_0))
       (let (b (get$2$2 func_arg_0))
           (mul (add a 2.0) (add b 3.0)))))

tests may be a bit over the top, this is fairly simple. (And the version taking a list of ASTNodes may never be needed, but it is...one line)