Add size demo
This commit is contained in:
parent
cbf23bc569
commit
88b1c71695
@ -34,6 +34,9 @@ tricu > "Stem"
|
||||
tricu < -- We can even convert a term back to source code (/demos/toSource.tri)
|
||||
tricu < toSource not?
|
||||
tricu > "(t (t (t t) (t t t)) (t t (t t t)))"
|
||||
tricu < -- or calculate its size (/demos/size.tri)
|
||||
tricu < size not?
|
||||
tricu > 12
|
||||
```
|
||||
|
||||
## Installation and Use
|
||||
|
19
demos/size.tri
Normal file
19
demos/size.tri
Normal file
@ -0,0 +1,19 @@
|
||||
compose = (\f g x : f (g x))
|
||||
|
||||
succ = y (\self :
|
||||
triage
|
||||
1
|
||||
t
|
||||
(triage
|
||||
(t (t t))
|
||||
(\_ tail : t t (self tail))
|
||||
t))
|
||||
|
||||
size = (\x :
|
||||
(y (\self x :
|
||||
compose succ
|
||||
(triage
|
||||
(\x : x)
|
||||
self
|
||||
(\x y : compose (self x) (self y))
|
||||
x)) x 0))
|
@ -43,4 +43,4 @@ toSource_ = y (\self arg :
|
||||
toSource = (\v : toSource_ v "")
|
||||
|
||||
exampleOne = toSource true -- OUT: "(t t)"
|
||||
exampleTwo = toSource not -- OUT: "(t (t (t t) (t t t)) (t t (t t t)))"
|
||||
exampleTwo = toSource not? -- OUT: "(t (t (t t) (t t t)) (t t (t t t)))"
|
||||
|
Loading…
x
Reference in New Issue
Block a user