-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathmain.neva
54 lines (50 loc) · 1.27 KB
/
main.neva
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
49
50
51
52
53
54
import { fmt }
def Main(start any) (stop any) {
print For<int>{Next2Lines}
wait Wait
panic Panic
---
:start -> 99..-1 -> print
print:res -> wait -> :stop
print:err -> panic
}
def Next2Lines(data int) (res any, err error) {
first Tap<int>{FirstLine}?
dec Dec<int>
second SecondLine?
---
:data -> first
first:res -> dec -> second -> :res
}
def FirstLine(data int) (res any, err error) {
p1 fmt.Println?
p2 fmt.Println?
p3 fmt.Printf?
---
:data -> switch {
0 -> 'No more bottles of beer on the wall, no more bottles of beer.' -> p1
1 -> '1 bottle of beer on the wall, 1 bottle of beer.' -> p2
_ -> [
p3:args[0],
'$0 bottles of beer on the wall, $0 bottles of beer.\n' -> p3:tpl
]
}
[p1:res, p2:res, p3:sig] -> :res
}
def SecondLine(data int) (res any, err error) {
p1 fmt.Println?
p2 fmt.Println?
p3 fmt.Println?
p4 fmt.Printf?
---
:data -> switch {
-1 -> 'Go to the store and buy some more, 99 bottles of beer on the wall.' -> p1
0 -> 'Take one down and pass it around, no more bottles of beer on the wall.\n' -> p2
1 -> 'Take one down and pass it around, 1 bottle of beer on the wall.\n' -> p3
_ -> [
p4:args[0],
'Take one down and pass it around, $0 bottles of beer on the wall.\n\n' -> p4:tpl
]
}
[p1:res, p2:res, p3:res, p4:sig] -> :res
}