]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of http://github.com/mrjbq7/factor
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 26 Jul 2010 19:10:50 +0000 (15:10 -0400)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 26 Jul 2010 19:10:50 +0000 (15:10 -0400)
basis/db/db-docs.factor
basis/math/combinatorics/combinatorics-tests.factor
basis/math/combinatorics/combinatorics.factor

index 13af6d10903d86d1a9f99ad59f799efda87a2263..66c9f32f7fcf39b383fc99933913e595d827d858 100644 (file)
@@ -27,7 +27,7 @@ HELP: dispose-statements
 { $description "Disposes an associative list of statements." } ;
 
 HELP: statement
-{ $description "A " { $snippet "statement" } " stores the information about a statemen, such as the SQL statement text, the in/out parameters, and type information." } ;
+{ $description "A " { $snippet "statement" } " stores the information about a statement, such as the SQL statement text, the in/out parameters, and type information." } ;
 
 HELP: result-set
 { $description "An object encapsulating a raw SQL result object. There are two ways in which a result set can be accessed, but they are specific to the database backend in use."
index 8a551bfe9de828c69dc4646e8e4da3dad1014434..6bd75cd3c526a1154909d463fb25a9204b922a77 100644 (file)
@@ -78,7 +78,7 @@ IN: math.combinatorics.tests
 
 [ { } ] [ { 1 2 } 0 selections ] unit-test
 
-[ { { 1 2 } } ] [ { 1 2 } 1 selections ] unit-test
+[ { { 1 } { 2 } } ] [ { 1 2 } 1 selections ] unit-test
 
 [ { { 1 1 } { 1 2 } { 2 1 } { 2 2 } } ]
 [ { 1 2 } 2 selections ] unit-test
index b69867fb12c6890221e2a8cac86c5b138b629e96..b1e28643895a3c39e6b41c3ae2dae9ab71d812eb 100644 (file)
@@ -1,8 +1,10 @@
 ! Copyright (c) 2007-2010 Slava Pestov, Doug Coleman, Aaron Schaefer, John Benediktsson.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs binary-search fry kernel locals math math.order
-    math.ranges namespaces sequences sorting make sequences.deep arrays
-    combinators ;
+
+USING: accessors arrays assocs binary-search fry kernel locals
+math math.order math.ranges namespaces sequences sequences.deep
+sorting ;
+
 IN: math.combinatorics
 
 <PRIVATE
@@ -129,21 +131,14 @@ PRIVATE>
     [ -rot ] dip each-combination ; inline
 
 : all-subsets ( seq -- subsets )
-    dup length [0,b] [
-        [ dupd all-combinations [ , ] each ] each
-    ] { } make nip ;
+    dup length [0,b] [ all-combinations ] with map concat ;
 
 : (selections) ( seq n -- selections )
-    dupd [ dup 1 > ] [
-        swap pick cartesian-product [
-            [ [ dup length 1 > [ flatten ] when , ] each ] each
-        ] { } make swap 1 -
-    ] while drop nip ;
+    [ [ 1array ] map dup ] [ 1 - ] bi*
+    [ cartesian-product concat ] with times
+    [ flatten ] map ;
 
 : selections ( seq n -- selections )
-    {
-        { 0 [ drop { } ] }
-        { 1 [ 1array ] }
-        [ (selections) ]
-    } case ;
+    dup 0 > [ (selections) ] [ 2drop { } ] if ;
+