aboutsummaryrefslogtreecommitdiff
path: root/test.pr
blob: e82209bd4a4c8f53d9602b3fe05ac15569306bd5 (plain)
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
48
zerop(0) is
  true
end
zerop(_) is
  false
end

fib(0) is
  1
end
fib(1) is
  1
end
fib(x) is
  fib(x-1) + fib(x-2)
end

add(x, y) is
  x + y
end

puts add(1, 2)
puts fib(5)

putser(string) is
  puts string
end
putser("foo")

varity(_) is
  puts "one thing"
end
varity(_, _) is
  puts "two things"
end
varity(1)
varity(1,2)

iffy(true, this, _) is
  this.call
end
iffy(false, _, that) is
  that.call
end
thisser = Proc.new { puts "This" }
thatter = Proc.new { puts "That" }
iffy(4>3, thisser, thatter)
iffy(3>4, thisser, thatter)