tricu/demos/size.tri
James Eversole 63504ba939 Rough draft of modules
This includes a naive implementation of a module system where imported
files have their imports recursively handled, strips the module/import
AST nodes, and then evals everything into a flat environment using
namespace prefixes like "Module.function".
2025-01-27 12:24:30 -06:00

26 lines
379 B
Plaintext

!module Size
!import "lib/base.tri" Lib
main = size size
compose = \f g x : f (g x)
succ = Lib.y (\self :
Lib.triage
1
t
(Lib.triage
(t (t t))
(\_ Lib.tail : t t (self Lib.tail))
t))
size = (\x :
(Lib.y (\self x :
compose succ
(Lib.triage
(\x : x)
self
(\x y : compose (self x) (self y))
x)) x 0))