1
1
mirror of https://github.com/anoma/juvix.git synced 2024-11-30 14:13:27 +03:00
juvix/tests/Core/positive/test034.jvc
Łukasz Czajka 39ef069bfc
Fold lets when the bound variable occurs at most once (#2231)
For example, convert
```
let x := f a b c in
g x
```
to
```
g (f a b c)
```
2023-06-29 13:02:10 +02:00

22 lines
527 B
Plaintext

-- evaluation order
def g := \x trace x >>> g;
def f := \x \y if x = 0 then 9 else trace 1 >>> (f (x - 1) (y 0));
def h := \x trace 8 >>> trace x >>> x + x;
def const := \x \y y >>> x;
type list {
nil : list;
cons : Any -> list -> list;
};
trace (const 0 (trace "!" >>> 1)) >>>
trace (const 0 (trace "a" >>> cons 1 (trace "b" >>> trace "c" >>> cons 1 (trace "d" >>> nil)))) >>>
trace ((\x \y \z x >>> trace "2" >>> x + y + (trace "3" >>> z)) (trace "1" >>> 1) 2 3) >>>
trace (f 5 g) >>>
trace 7 >>>
h (trace 2 >>> 3)