diff --git a/doc/RETRO-Book.md b/doc/RETRO-Book.md index f3804a2..634c256 100644 --- a/doc/RETRO-Book.md +++ b/doc/RETRO-Book.md @@ -2469,6 +2469,15 @@ Be careful with recursion as the virtual machine will have a limited amount of space for the address stack and recursing too many times can cause a stack overflow. +## Conditional Loops + +There are two conditional looping combinators: `while` and `until`. +Both take a quote and execute it, checking a returned flag to decide +when to stop running. + + #0 [ dup n:put sp n:inc dup #10 eq? ] until + #10 [ dup n:put sp n:dec dup n:-zero? ] while + ## Counted Loops There are two combinators for counted loops. These are `times` and diff --git a/doc/book/techniques/loops b/doc/book/techniques/loops index 9cb9396..dca85f3 100644 --- a/doc/book/techniques/loops +++ b/doc/book/techniques/loops @@ -27,6 +27,15 @@ Be careful with recursion as the virtual machine will have a limited amount of space for the address stack and recursing too many times can cause a stack overflow. +## Conditional Loops + +There are two conditional looping combinators: `while` and `until`. +Both take a quote and execute it, checking a returned flag to decide +when to stop running. + + #0 [ dup n:put sp n:inc dup #10 eq? ] until + #10 [ dup n:put sp n:dec dup n:-zero? ] while + ## Counted Loops There are two combinators for counted loops. These are `times` and