Dutch national flag problem: Difference between revisions

Content added Content deleted
(Added Quackery.)
Line 3,379: Line 3,379:
[ 3 ] is blue ( --> n )
[ 3 ] is blue ( --> n )


[ true swap
[ true swap
behead do swap
behead do swap
witheach
witheach
[ do tuck > if
[ do tuck > if
[ dip not
[ dip not
conclude ] ]
conclude ] ]
drop ] is sorted ( [ --> b )
drop ] is sorted ( [ --> b )

[] ' [ red white blue ]
witheach
[ swap
4 random 1+ times
[ over nested join ]
nip ]

[ shuffle dup sorted not until ]


[] 4 random 1+ times [ ' red nested join ]
4 random 1+ times [ ' white nested join ]
4 random 1+ times [ ' blue nested join ]
[ shuffle dup sorted not until ]
say "Before sorting: " dup echo cr
say "Before sorting: " dup echo cr
say " After sorting: " sortwith [ dip do do > ] echo cr</syntaxhighlight>
say " After sorting: " sortwith [ dip do do > ] echo cr</syntaxhighlight>