bottles-of-beer.nv
· 1.6 KiB · Text
Eredeti
Playground
|| :keyword for 'if': say
:keyword for 'else': otherwise-say
|| :: 99 bottles of beer
|:: $n bottles of beer|
:: $n bottles of beer on the wall!
:: $n bottles of beer!
:: You take one down, pass it around!
:: when $n is 1 :: say
:: No more bottles of beer on the wall!
:: otherwise-say
:: $n - 1 bottles of beer on the wall!
:: $n - 1 bottles of beer
:: end
|:: 1 bottles of beer on the wall!|
:: print (formatted)
:message: "1 bottle of beer on the wall!\n"
|:: $n bottles of beer on the wall!|
:: print (formatted)
:message: "{%d} bottles of beer on the wall!\n"
:arguments: $n :arguments
|:: 1 bottles of beer!|
:: print (formatted)
:message: "1 bottle of beer!\n"
|:: $n bottles of beer!|
:: print (formatted)
:message: "{%d} bottles of beer!\n"
:arguments: $n :arguments
|:: You take one down, pass it around!|
:: print (formatted)
:message: "You take one down, pass it around!\n"
|:: when $n is $n|
|:: when $n is $m| :: false
|:: $_ - 1 bottles of beer on the wall! :@math: 1|
:: print (formatted)
:message: "1 bottle of beer on the wall!\n\n"
|:: $_ - 1 bottles of beer on the wall! :@math: $n|
:: print (formatted)
:message: "{%d} bottle of beer on the wall!\n\n"
:arguments: $n :arguments:
|:: $n - 1 bottles of beer on the wall!?|
:@math: subtract $n 1
|:: $_ - 1 bottles of beer :@math: $n| :: $n bottles of beer
|:: $n - 1 bottles of beer?| :@math: subtract $n 1
|:: No more bottles of beer on the wall!|
:: print (formatted)
:message: "No more bottles of beer on the wall!\n"
1 | || :keyword for 'if': say |
2 | :keyword for 'else': otherwise-say |
3 | |
4 | || :: 99 bottles of beer |
5 | |
6 | |:: $n bottles of beer| |
7 | :: $n bottles of beer on the wall! |
8 | :: $n bottles of beer! |
9 | :: You take one down, pass it around! |
10 | :: when $n is 1 :: say |
11 | :: No more bottles of beer on the wall! |
12 | :: otherwise-say |
13 | :: $n - 1 bottles of beer on the wall! |
14 | :: $n - 1 bottles of beer |
15 | :: end |
16 | |
17 | |:: 1 bottles of beer on the wall!| |
18 | :: print (formatted) |
19 | :message: "1 bottle of beer on the wall!\n" |
20 | |:: $n bottles of beer on the wall!| |
21 | :: print (formatted) |
22 | :message: "{%d} bottles of beer on the wall!\n" |
23 | :arguments: $n :arguments |
24 | |
25 | |:: 1 bottles of beer!| |
26 | :: print (formatted) |
27 | :message: "1 bottle of beer!\n" |
28 | |:: $n bottles of beer!| |
29 | :: print (formatted) |
30 | :message: "{%d} bottles of beer!\n" |
31 | :arguments: $n :arguments |
32 | |
33 | |:: You take one down, pass it around!| |
34 | :: print (formatted) |
35 | :message: "You take one down, pass it around!\n" |
36 | |
37 | |:: when $n is $n| |
38 | |:: when $n is $m| :: false |
39 | |
40 | |:: $_ - 1 bottles of beer on the wall! :@math: 1| |
41 | :: print (formatted) |
42 | :message: "1 bottle of beer on the wall!\n\n" |
43 | |:: $_ - 1 bottles of beer on the wall! :@math: $n| |
44 | :: print (formatted) |
45 | :message: "{%d} bottle of beer on the wall!\n\n" |
46 | :arguments: $n :arguments: |
47 | |:: $n - 1 bottles of beer on the wall!?| |
48 | :@math: subtract $n 1 |
49 | |
50 | |:: $_ - 1 bottles of beer :@math: $n| :: $n bottles of beer |
51 | |:: $n - 1 bottles of beer?| :@math: subtract $n 1 |
52 | |
53 | |:: No more bottles of beer on the wall!| |
54 | :: print (formatted) |
55 | :message: "No more bottles of beer on the wall!\n" |
conditions.nv
· 1.8 KiB · Text
Eredeti
Playground
|::|
:keyword for 'if': then
:keyword for 'end': end
:keyword for 'else': else
:keyword for 'fail': false
| :keyword for 'fail': $fail? :: $fail?
:keyword for 'if': $if? :: $if |
:conditional depth:
| :keyword for 'fail': $fail? :: $fail?
:keyword for 'else': $else? :: $else
:conditional depth:? :conditional depth:? |
| :keyword for 'fail': $fail? :: $fail
:keyword for 'else': $else? :: $else
:conditional depth: |
| :keyword for 'fail': $fail? :: $fail?
:keyword for 'end': $end? :: $end
:conditional depth:? :conditional depth: |
| :keyword for 'fail': $fail? :: $fail
:keyword for 'end': $end? :: $end
:conditional depth: |
| :keyword for 'fail': $fail? :: $fail
:keyword for 'end': $end? :: $end |
| :keyword for 'fail': $fail? :: $fail?
:: $1 |
| :keyword for 'fail': $fail? :: $fail?
:: $1 $2 |
| :keyword for 'fail': $fail? :: $fail?
:: $1 $2 $3 |
| :keyword for 'fail': $fail? :: $fail?
:: $1 $2 $3 $4 |
| :keyword for 'fail': $fail? :: $fail?
:: $1 $2 $3 $4 $5 |
| :keyword for 'fail': $fail? :: $fail?
:: $1 $2 $3 $4 $5 $6 |
| :keyword for 'fail': $fail? :: $fail?
:: $1 $2 $3 $4 $5 $6 $7 |
| :keyword for 'fail': $fail? :: $fail?
:: $1 $2 $3 $4 $5 $6 $7 $8 |
| :keyword for 'fail': $fail? :: $fail?
:: $1 $2 $3 $4 $5 $6 $7 $8 $9 |
| :keyword for 'fail': $fail? :: $fail?
:: $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 |
| :keyword for 'fail': $fail? :: $fail |
|:keyword for 'else': $else? :: $else :keyword for 'fail': $fail?| :: $fail :conditional depth:
|:keyword for 'if': $if? :: $if|
|:keyword for 'end': $end? :: $end|
1 | |::| |
2 | :keyword for 'if': then |
3 | :keyword for 'end': end |
4 | :keyword for 'else': else |
5 | :keyword for 'fail': false |
6 | |
7 | | :keyword for 'fail': $fail? :: $fail? |
8 | :keyword for 'if': $if? :: $if | |
9 | :conditional depth: |
10 | | :keyword for 'fail': $fail? :: $fail? |
11 | :keyword for 'else': $else? :: $else |
12 | :conditional depth:? :conditional depth:? | |
13 | | :keyword for 'fail': $fail? :: $fail |
14 | :keyword for 'else': $else? :: $else |
15 | :conditional depth: | |
16 | | :keyword for 'fail': $fail? :: $fail? |
17 | :keyword for 'end': $end? :: $end |
18 | :conditional depth:? :conditional depth: | |
19 | | :keyword for 'fail': $fail? :: $fail |
20 | :keyword for 'end': $end? :: $end |
21 | :conditional depth: | |
22 | | :keyword for 'fail': $fail? :: $fail |
23 | :keyword for 'end': $end? :: $end | |
24 | |
25 | | :keyword for 'fail': $fail? :: $fail? |
26 | :: $1 | |
27 | | :keyword for 'fail': $fail? :: $fail? |
28 | :: $1 $2 | |
29 | | :keyword for 'fail': $fail? :: $fail? |
30 | :: $1 $2 $3 | |
31 | | :keyword for 'fail': $fail? :: $fail? |
32 | :: $1 $2 $3 $4 | |
33 | | :keyword for 'fail': $fail? :: $fail? |
34 | :: $1 $2 $3 $4 $5 | |
35 | | :keyword for 'fail': $fail? :: $fail? |
36 | :: $1 $2 $3 $4 $5 $6 | |
37 | | :keyword for 'fail': $fail? :: $fail? |
38 | :: $1 $2 $3 $4 $5 $6 $7 | |
39 | | :keyword for 'fail': $fail? :: $fail? |
40 | :: $1 $2 $3 $4 $5 $6 $7 $8 | |
41 | | :keyword for 'fail': $fail? :: $fail? |
42 | :: $1 $2 $3 $4 $5 $6 $7 $8 $9 | |
43 | | :keyword for 'fail': $fail? :: $fail? |
44 | :: $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 | |
45 | | :keyword for 'fail': $fail? :: $fail | |
46 | |
47 | |:keyword for 'else': $else? :: $else :keyword for 'fail': $fail?| :: $fail :conditional depth: |
48 | |:keyword for 'if': $if? :: $if| |
49 | |:keyword for 'end': $end? :: $end| |
50 |
print-format.nv
· 944 B · Text
Eredeti
Playground
|:: print (formatted)? :message: "{%d}" :arguments:|
|:: print (formatted)? :message: "{%d}" :arguments: $n|
:message: "{}"
:: collect digits of $n
|:: collect digits of $n :div: 0 :mod: $mod|
:: add digit to message $mod
|:: collect digits of $n :div: $div :mod: $mod|
:: add digit to message $mod
:: collect digits of $div
|:: collect digits of $n?|
:: divide by 10 :@math: divide $n 10
:: mod by 10 :@math: modulo $n 10
|:: divide by 10 :@math: $div|
:div: $div
|:: mod by 10 :@math: $mod|
:mod: $mod
|:: add digit to message $n :@math: $char|
:message: $char
|:: add digit to message $n?|
:@math: add 48 $n
|:: print (formatted)? :message: "{}" :arguments: |
|:: print (formatted)? :message: "{}"? :arguments: $char|
:@stdio: write $char
|:: print (formatted)? :message: "\n"|
:@stdio: write 10
|:: print (formatted)? :message: $char|
:@stdio: write $char
|:: print (formatted)|
1 | |:: print (formatted)? :message: "{%d}" :arguments:| |
2 | |:: print (formatted)? :message: "{%d}" :arguments: $n| |
3 | :message: "{}" |
4 | :: collect digits of $n |
5 | |
6 | |:: collect digits of $n :div: 0 :mod: $mod| |
7 | :: add digit to message $mod |
8 | |:: collect digits of $n :div: $div :mod: $mod| |
9 | :: add digit to message $mod |
10 | :: collect digits of $div |
11 | |:: collect digits of $n?| |
12 | :: divide by 10 :@math: divide $n 10 |
13 | :: mod by 10 :@math: modulo $n 10 |
14 | |
15 | |:: divide by 10 :@math: $div| |
16 | :div: $div |
17 | |:: mod by 10 :@math: $mod| |
18 | :mod: $mod |
19 | |
20 | |:: add digit to message $n :@math: $char| |
21 | :message: $char |
22 | |:: add digit to message $n?| |
23 | :@math: add 48 $n |
24 | |
25 | |
26 | |:: print (formatted)? :message: "{}" :arguments: | |
27 | |:: print (formatted)? :message: "{}"? :arguments: $char| |
28 | :@stdio: write $char |
29 | |:: print (formatted)? :message: "\n"| |
30 | :@stdio: write 10 |
31 | |:: print (formatted)? :message: $char| |
32 | :@stdio: write $char |
33 | |:: print (formatted)| |