]> gitweb.factorcode.org Git - factor.git/blobdiff - unmaintained/adsoda/combinators/combinators.factor
core, basis, extra: Remove DOS line endings from files.
[factor.git] / unmaintained / adsoda / combinators / combinators.factor
index 52a5b83c5180e3dc7a2c2d2dc0ac441fb6163c49..dfa01304927938589a00063ade55369d61a5ad79 100644 (file)
@@ -1,45 +1,45 @@
-! Copyright (C) 2008 Jeff Bigot\r
-! See http://factorcode.org/license.txt for BSD license.\r
-USING: kernel arrays sequences fry math combinators ;\r
-\r
-IN: adsoda.combinators\r
-\r
-! : (combinations) ( seq -- seq ) [ 1 tail ] dip combinations ;\r
-\r
-! : prefix-each [ prefix ] curry map ; inline\r
-\r
-! : combinations ( seq n -- seqs )\r
-!    {\r
-!        { [ dup 0 = ] [ 2drop { { } } ] }\r
-!        { [ over empty? ] [ 2drop { } ] }\r
-!        { [ t ] [ \r
-!            [ [ 1 - (combinations) ] [ drop first ] 2bi prefix-each ]\r
-!            [ (combinations) ] 2bi append\r
-!        ] }\r
-!    } cond ;\r
-\r
-: columnize ( array -- array ) [ 1array ] map ; inline\r
-\r
-: among ( array n -- array )\r
-    2dup swap length \r
-    {\r
-        { [ over 1 = ] [ 3drop columnize ] }\r
-        { [ over 0 = ] [ 4drop { } ] }\r
-        { [ 2dup < ] [ 2drop [ 1 cut ] dip\r
-                         [ 1 - among [ append ] with map ]\r
-                         [ among append ] 2bi\r
-                       ] }\r
-        { [ 2dup = ] [ 3drop 1array ] }\r
-        { [ 2dup > ] [ 4drop { } ] }\r
-    } cond\r
-;\r
-\r
-: concat-nth ( seq1 seq2 -- seq )\r
-    [ nth append ] curry map-index ;\r
-\r
-: do-cycle   ( array -- array )   dup first suffix ;\r
-\r
-: map-but ( seq i quot -- seq )\r
-    ! quot : ( seq x -- seq )\r
-    '[ _ = [ @ ] unless ] map-index ; inline\r
-\r
+! Copyright (C) 2008 Jeff Bigot
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel arrays sequences fry math combinators ;
+
+IN: adsoda.combinators
+
+! : (combinations) ( seq -- seq ) [ 1 tail ] dip combinations ;
+
+! : prefix-each [ prefix ] curry map ; inline
+
+! : combinations ( seq n -- seqs )
+!    {
+!        { [ dup 0 = ] [ 2drop { { } } ] }
+!        { [ over empty? ] [ 2drop { } ] }
+!        { [ t ] [ 
+!            [ [ 1 - (combinations) ] [ drop first ] 2bi prefix-each ]
+!            [ (combinations) ] 2bi append
+!        ] }
+!    } cond ;
+
+: columnize ( array -- array ) [ 1array ] map ; inline
+
+: among ( array n -- array )
+    2dup swap length 
+    {
+        { [ over 1 = ] [ 3drop columnize ] }
+        { [ over 0 = ] [ 4drop { } ] }
+        { [ 2dup < ] [ 2drop [ 1 cut ] dip
+                         [ 1 - among [ append ] with map ]
+                         [ among append ] 2bi
+                       ] }
+        { [ 2dup = ] [ 3drop 1array ] }
+        { [ 2dup > ] [ 4drop { } ] }
+    } cond
+;
+
+: concat-nth ( seq1 seq2 -- seq )
+    [ nth append ] curry map-index ;
+
+: do-cycle   ( array -- array )   dup first suffix ;
+
+: map-but ( seq i quot -- seq )
+    ! quot : ( seq x -- seq )
+    '[ _ = [ @ ] unless ] map-index ; inline
+