]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/sequences/deep/deep.factor
core: subseq-index? -> subseq-of?
[factor.git] / basis / sequences / deep / deep.factor
index d90c167b2a94df50dd2edf0babf02316122e3d19..9c1df0d31660f2cad577046e897385ad6026dfef 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2007, 2008 Daniel Ehrenberg, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: sequences kernel strings math fry ;
+USING: fry kernel make math sequences strings ;
 IN: sequences.deep
 
 ! All traversal goes in postorder
@@ -54,9 +54,9 @@ M: object branch? drop f ;
         _ swap dup branch? [ member? ] [ 2drop f ] if
     ] deep-find >boolean ;
 
-: deep-subseq? ( seq subseq -- ? )
-    '[
-        dup branch? [ _ subseq? ] [ drop f ] if
+: deep-subseq-of? ( seq subseq -- ? )
+   '[
+        _ over branch? [ subseq-of? ] [ 2drop f ] if
     ] deep-find >boolean ;
 
 : deep-map! ( ... obj quot: ( ... elt -- ... elt' ) -- ... obj )
@@ -69,3 +69,12 @@ M: object branch? drop f ;
 
 : flatten-as ( obj exemplar -- seq )
     [ branch? ] swap deep-reject-as ;
+
+: flatten1 ( obj -- seq )
+    [
+        [
+            dup branch? [
+                [ dup branch? [ % ] [ , ] if ] each
+            ] [ , ] if
+        ]
+    ] keep dup branch? [ drop f ] unless make ;