]> gitweb.factorcode.org Git - factor.git/commitdiff
basis/extra: using smart-loop.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 4 Apr 2021 04:00:55 +0000 (21:00 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 4 Apr 2021 04:00:55 +0000 (21:00 -0700)
basis/retries/retries.factor
extra/24-game/24-game.factor
extra/minesweeper/minesweeper.factor

index 22fff548a5588b9294c317d7afa373ecd61033c5..e3ecccc53c23523a9aa993e547f3f090fcfabe97 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2021 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays calendar combinators combinators.extras
+USING: accessors arrays calendar combinators combinators.smart
 continuations kernel math math.functions math.parser math.ranges
 namespaces prettyprint random sequences system threads ;
 IN: retries
@@ -70,7 +70,7 @@ ERROR: retries-failed retries quot ;
             ] [
                 current-retries get _ retries-failed
             ] if
-        ] loop1
+        ] smart-loop
     ] with-variable ; inline
 
 : retries ( quot time-strategy n/seq -- result )
index 7dc68f89b4cc5f92dfc98a1525afcdfa28abb084..ec7810d8b68a4e7d89e1e56d770ee70e25926340 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright © 2008 Reginald Keith Ford II
 ! 24, the Factor game!
-USING: accessors backtrack combinators continuations formatting fry io
-kernel math prettyprint quotations random sequences ;
+USING: accessors backtrack combinators combinators.smart
+continuations formatting fry io kernel math prettyprint
+quotations random sequences ;
 IN: 24-game
 
 : nop ( -- ) ;
@@ -29,7 +30,7 @@ IN: 24-game
     4 [ 10 random ] replicate ;
 
 : make-24 ( -- array )
-    f [ dup first4 makes-24? ] [ drop random-4 ] do until ;
+    [ random-4 dup first4 makes-24? not ] smart-loop ;
 
 : q ( -- obj ) "quit" ;
 
index eb96279e4acc958fd847b0387ed151f1cb576b64..481ca7bd061c82e4e293a717735e159faf202c6d 100644 (file)
@@ -3,11 +3,12 @@
 
 USING: accessors arrays assocs calendar circular
 colors.constants combinators combinators.short-circuit
-destructors formatting fry images.loader kernel locals math
-math.order math.parser namespaces opengl opengl.textures random
-sequences timers ui ui.commands ui.gadgets ui.gadgets.toolbar
-ui.gadgets.tracks ui.gadgets.worlds ui.gestures ui.pens.solid
-ui.render ui.tools.browser words ;
+combinators.smart destructors formatting fry images.loader
+kernel locals math math.order math.parser namespaces opengl
+opengl.textures random sequences timers ui ui.commands
+ui.gadgets ui.gadgets.toolbar ui.gadgets.tracks
+ui.gadgets.worlds ui.gestures ui.pens.solid ui.render
+ui.tools.browser words ;
 
 IN: minesweeper
 
@@ -40,7 +41,7 @@ TUPLE: cell #adjacent mined? state ;
     [ #mines ] [ #flagged ] bi - ;
 
 : unmined-cell ( cells -- cell )
-    f [ dup mined?>> ] [ drop dup random random ] do while nip ;
+    '[ _ random random dup mined?>> ] smart-loop ;
 
 : place-mines ( cells n -- cells )
     [ dup unmined-cell t >>mined? drop ] times ;