view samples/fibmacro.tp @ 298:647f7a2d253b

Committing a simple macro example I put together a while ago
author Michael Pavone <pavone@retrodev.com>
date Thu, 24 Jul 2014 23:55:59 -0700
parents
children
line wrap: on
line source
#{
fib <- :n {
	if: n < 2 {
		1
	} else: {
		(fib: n-1) + (fib: n-2)
	}
}
fibm <- macro: :n {
	eval: n :n {
		fib: n
	} else: {
		quote: (fib: n)
	}
}

main <- {
	print: (string: (fibm: 20)) . "\n"
}

}