-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbench.pn
50 lines (43 loc) · 1.11 KB
/
bench.pn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
say = (msg): msg string print, "\n" print.
say2 = (label, value): label print, ": " print, value print, "\n" print.
say("Hello...")
Fibber = Object delegated
say("Object delegated")
# We want to call it "subclass", not "delegated".
# But it doesn't work: lookup failed: "0 subclass"
# Object def("subclass", (): return self delegated.)
# say("Defined 'subclass' as a synonym for 'delegated'.")
#
# Fibber = Object subclass
# say("Object subclassed")
Fibber def("fib", (n):
say("in fib")
say(n)
if (n < 2):
say("n < 2")
# I can't get this to work no matter what:
# return(1)
# Nor any of this:
# result = 1
# say2("result", result)
# say2("1", 1)
# This isn't working either:
# They all fail when trying to print the "1", lookup failed on 'print'.
1
.
else:
say("n >= 2")
x = self fib(n-2)
say("got x")
say2("x", x)
y = self fib(n-1)
say2("y", y)
say2("x + y + 1", x + y + 1)
return(x + y + 1)
# Doesn't work, returns nil.
# return self fib(n-2) + self fib(n-1) + 1
.
.)
fibber = Fibber allocate
num_sends = fibber fib(10)
"num_sends: " print, num_sends string print, "\n" print