Number reversal game: Difference between revisions

Added check for the "already sorted" case
(Added check for the "already sorted" case)
Line 924:
 
=={{header|PicoLisp}}==
{{incorrect|PicoLisp|Example is likely to fail if numbers are initially randomly shuffled to the ordered state. (See talk).}}
<lang PicoLisp>(load "@lib/simul.l")
 
(de reversalGame ()
(let (SortLst (shuffle (range 1 9) Lst (shuffle Sort) Cnt 0)
(while (apply < Lst)
(setq Lst (shuffle Lst)) )
(loop
(printsp Lst)
(T (=apply Lst< SortLst) Cnt)
(NIL (num? (read)))
(setq Lst (flip Lst @))
(inc 'Cnt) ) ) )</lang>
Output:
<pre>: (reversalGame)
Anonymous user