Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed May 6, 2024
2 parents 381f6de + ba383a7 commit 3821eaf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
15 changes: 4 additions & 11 deletions eo-runtime/src/main/eo/org/eolang/while.eo
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,15 @@
# While.
[condition body] > while
if. > @
condition.as-bool
start 0
(condition 0).as-bool
loop 0
false

# First loop iteration that does not check condition.
[index] > start
seq > @
*
^.body index
^.loop (index.plus 1)

# Recursive
# Recursive loop.
[index] > loop
^.body index > current
if. > @
^.condition.as-bool
(^.condition (index.plus 1)).as-bool
seq
*
current
Expand Down
27 changes: 19 additions & 8 deletions eo-runtime/src/test/eo/org/eolang/while-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,22 @@
+package org.eolang
+version 0.0.0

# Test.
[] > while-dataizes-only-first-cycle
eq. > @
0
malloc.for
42
[m]
while > @
i.eq 0 > [i]
m.put i > [i]

# Test.
[] > simple-while-with-false-first
not. > @
while > res
false
false > [i]
true > [i]

# Test.
Expand All @@ -40,7 +51,7 @@
true
[m]
while > @
m
m > [i]
m.put false > [i]
false

Expand All @@ -51,15 +62,15 @@
0
[m]
while > @
2.gt m
2.gt m > [i]
m.put (m.as-int.plus 1) > [i]
3

# Test.
[] > last-while-dataization-object-with-false-condition
not. > @
while
1.gt 2
1.gt 2 > [i]
true > [i]

# Test.
Expand All @@ -78,7 +89,7 @@
acc.as-int.plus
arr.at 0
while
max.gt iter
max.gt iter > [i]
[i]
seq > @
*
Expand All @@ -100,7 +111,7 @@
0
[iter]
while > @
max.gt iter
max.gt iter > [i]
[i]
seq > @
*
Expand All @@ -122,7 +133,7 @@
0
[iter]
while > @
[]
[i]
if. > @
max.gt iter
seq
Expand All @@ -149,7 +160,7 @@
0
[iter]
while > @
[]
[i]
if. > @
max.gt iter
seq
Expand Down

0 comments on commit 3821eaf

Please sign in to comment.