annotate samples/fibmacro.tp @ 375:f8d80c16abbd

Add epoll module and a basic epoll sample
author Michael Pavone <pavone@retrodev.com>
date Fri, 14 Aug 2015 23:08:54 -0700
parents 647f7a2d253b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
298
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #{
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 fib <- :n {
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3 if: n < 2 {
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 1
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 } else: {
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 (fib: n-1) + (fib: n-2)
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 }
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 }
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 fibm <- macro: :n {
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 eval: n :n {
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 fib: n
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 } else: {
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 quote: (fib: n)
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 }
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 }
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 main <- {
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 print: (string: (fibm: 20)) . "\n"
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19 }
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20
647f7a2d253b Committing a simple macro example I put together a while ago
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 }