-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.kinder
More file actions
107 lines (89 loc) · 1.63 KB
/
program.kinder
File metadata and controls
107 lines (89 loc) · 1.63 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
function greet($name, $age) {
say Hello, $name! You are $age years old.
}
call greet(Foo, 34)
add(5,3,1,2,1000)
multiply(4, 2)
subtract(3,2)
divide(4,2)
function groot($GOOGK) {
say Welcome to $GOOGK!
repeat 3 {
say Hello!
}
}
call groot(FooBar)
say === More Fun Examples ===
function introduce($name, $hobby) {
say Meet $name!
say $name loves $hobby
say $name would like to do some math!
}
call introduce(Charlie, programming)
add(1, 2, 3)
multiply(2, 5)
call introduce(Diana, painting)
add(10, 20)
multiply(3, 4)
function countdown($number) {
say Counting down from $number...
repeat 3 {
say $number seconds left...
}
say Blast off!
}
call countdown(3)
say Doing some math magic:
add(10, 20, 30, 40)
multiply(5, 5, 2)
subtract(100, 50, 20)
divide(100, 5, 2)
function celebrate($name, $times) {
say Happy celebration, $name!
repeat 2 {
say Cheers!
}
say Celebration complete for $name!
}
call celebrate(Alice, 2)
multiply(2, 2)
call celebrate(Bob, 4)
multiply(4, 2)
say Nested repeat example:
repeat 2 {
say Outer loop iteration
repeat 3 {
say Inner loop
}
}
say Final calculation:
add(2, 2, 2, 2)
multiply(2, 2, 2)
say That was fun!
say More complex function example:
function mathShow($name) {
say Math show for $name!
say Get ready for amazing calculations!
say Thanks for watching, $name!
}
call mathShow(Eve)
say Performing math for Eve:
add(1, 2, 3, 4, 5)
multiply(3, 3, 3)
subtract(100, 20, 10)
divide(100, 2, 2)
call mathShow(Frank)
say Performing math for Frank:
add(2, 4, 6, 8)
multiply(2, 2, 2, 2)
say Triple nested repeat:
repeat 2 {
say First level
repeat 2 {
say Second level
repeat 2 {
say Third level!
}
}
}
say Program complete!