Loops/Continue: Difference between revisions
Content added Content deleted
Jazzedpineda (talk | contribs) (Omitted EasyLang) |
Simple9371 (talk | contribs) m (→{{header|Scheme}}: fix) |
||
Line 2,155: | Line 2,155: | ||
=={{header|Scheme}}== |
=={{header|Scheme}}== |
||
For R7RS Scheme. In this functional solution, there is no "continue". Instead, the "loop" function is directly called in the tail ([[Category:Recursion|tail recusrion]]). |
|||
{{incorrect|Scheme|}} |
{{incorrect|Scheme|}} |
||
<syntaxhighlight lang="scheme">( |
<syntaxhighlight lang="scheme">(import (scheme base) |
||
⚫ | |||
(if (> i 10) 'done |
|||
(begin |
|||
(define (loop-fn start end) |
|||
⚫ | |||
(define (loop i) |
|||
(if (> i end) #f |
|||
(begin |
|||
(display i) |
|||
(cond ((zero? (modulo i 5)) |
|||
(newline) (loop (+ 1 i))) |
|||
(else |
|||
(display ", ") |
|||
(loop (+ 1 i))))))) |
|||
(loop start)) |
|||
(loop-fn 1 10)</syntaxhighlight> |
|||
=={{header|Scilab}}== |
=={{header|Scilab}}== |