Dutch national flag problem: Difference between revisions

m
→‎{{header|REXX}}: added DO-END labels, changed DO loop indentation, changed comments, added comments. -- ~~~~
(Added PicoLisp)
m (→‎{{header|REXX}}: added DO-END labels, changed DO loop indentation, changed comments, added comments. -- ~~~~)
Line 502:
end /*g*/
 
say 'number of colored balls generated = ' N ; say
say 'original ball order:'
say @ ; say
$=; do j=1 for endNcolors
$=
do j_=1 for Ncolorsword(colors,j)
$=$ copies(_' ',countWords(_=word(colors,j@))
end $=$ copies(_' ',countWords(_,@))/*j*/
end
say ' sorted ball order:'
say space($); say
 
do jk=2 to N /*ensure sortedthe balls are in order. */
if wordpos(word($,jk),colors)>=wordpos(word($,jk-1),colors) then iterate
say "The list of sorted balls isn't in proper order!"; exit 13
end /*k*/
 
say ' sorted ball list has been confirmed as being sorted correctly.'
exit /*stick a fork in it, we're done.*/
exit
/*──────────────────────────────────COUNTWORDS subroutine───────────────*/
countWords: procedure; parse arg ?,hay; s=1