{ $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."
[ { } ] [ { 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
! 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
[ -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 ;
+