September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
34
Task/Loops-For/Dodo0/loops-for.dodo0
Normal file
34
Task/Loops-For/Dodo0/loops-for.dodo0
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
fun for -> var, test, body, return # define a for loop using recursion
|
||||
(
|
||||
test(var) -> continue
|
||||
if (continue) ->
|
||||
(
|
||||
body(var) -> var
|
||||
for (var, test, body, return)
|
||||
)
|
||||
|
|
||||
return(var)
|
||||
)
|
||||
| for
|
||||
|
||||
fun upToFive (-> index, return) '<='(index, 5, return) | upToFive
|
||||
|
||||
for (1, upToFive) -> index, return
|
||||
(
|
||||
fun countTheStars -> stars, return
|
||||
(
|
||||
'count'(stars) -> n
|
||||
'<'(n, index, return) # continue until n = index
|
||||
)
|
||||
| countTheStars
|
||||
|
||||
for ("*", countTheStars) -> prefix, return
|
||||
'str'(prefix, "*", return)
|
||||
| stars
|
||||
|
||||
println(stars) ->
|
||||
|
||||
'inc'(index, return)
|
||||
)
|
||||
| result
|
||||
exit()
|
||||
Loading…
Add table
Add a link
Reference in a new issue