]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/rosetta-code/n-queens/n-queens.factor
factor: trim using lists
[factor.git] / extra / rosetta-code / n-queens / n-queens.factor
index 8b26a812c5d8fc2c27e804dc6cef399ba61e5840..f55981122e07c7a3bcea039a42400eabda1c61e0 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (c) 2012 Anonymous
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences math math.combinatorics formatting io locals ;
+USING: kernel sequences math math.combinatorics formatting io ;
 IN: rosetta-code.n-queens
 
 ! http://rosettacode.org/wiki/N-queens_problem
@@ -10,7 +10,7 @@ IN: rosetta-code.n-queens
 
 :: safe?  ( board q -- ? )
     [let q board nth :> x
-      q iota [
+      q <iota> [
          x swap
          [ board nth ] keep
          q swap -
@@ -20,10 +20,10 @@ IN: rosetta-code.n-queens
     ] ;
 
 : solution? ( board -- ? )
-    dup length iota [ dupd safe? ] all? nip ;
+    dup length <iota> [ dupd safe? ] all? nip ;
 
 : queens ( n -- l )
-    iota all-permutations [ solution? ] filter ;
+    <iota> all-permutations [ solution? ] filter ;
 
 : queens. ( n -- )
     queens [ [ 1 + "%d " printf ] each nl ] each ;