Loops/Continue: Difference between revisions
Content deleted Content added
Line 752: | Line 752: | ||
else |
else |
||
printf ", "</lang> |
printf ", "</lang> |
||
===Using [[Comma quibbling#The Function]]=== |
|||
===or not=== |
|||
;cf rc task 'comma quibbling' |
|||
<lang fsharp> |
<lang fsharp> |
||
let fN g=quibble (Seq.initInfinite(fun n ->if (n+1)%5=0 || (n+1)=List.length g then "\n" else ", ")) g |
|||
let quibble n= |
|||
fN [1] |> Seq.iter(fun(n,g)->printf "%d%s" n g) |
|||
let fN=List.mapi(fun n _->match n with n when n%5=0-> "\n" |_->", ") n |> List.rev |
|||
fN [1..9] |> Seq.iter(fun(n,g)->printf "%d%s" n g) |
|||
fN [1..10] |> Seq.iter(fun(n,g)->printf "%d%s" n g) |
|||
quibble [1..10] |
|||
fN [1..11] |> Seq.iter(fun(n,g)->printf "%d%s" n g) |
|||
</lang> |
</lang> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
1 |
|||
1, 2, 3, 4, 5 |
|||
6, 7, 8, 9 |
|||
1, 2, 3, 4, 5 |
|||
6, 7, 8, 9, 10 |
|||
1, 2, 3, 4, 5 |
1, 2, 3, 4, 5 |
||
6, 7, 8, 9, 10 |
6, 7, 8, 9, 10 |
||
11 |
|||
</pre> |
</pre> |
||
=={{header|Factor}}== |
=={{header|Factor}}== |