]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences.extras: remove insert-sorted (can use versions in sorting.extras instead).
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 8 Jan 2014 19:50:35 +0000 (11:50 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 8 Jan 2014 19:50:35 +0000 (11:50 -0800)
extra/sequences/extras/extras-tests.factor
extra/sequences/extras/extras.factor

index aaa405219e3215b01a94c251a49da75cad8eeb8b..abd15a7b62efbc93df4bab409138c5245ab07eb9 100644 (file)
@@ -4,12 +4,6 @@ tools.test vectors ;
 
 IN: sequences.extras.tests
 
-{ V{ 0 1 2 3 4 5 6 7 8 9 } } [
-    V{ } clone
-    10 iota >array randomize
-    [ swap insert-sorted ] each
-] unit-test
-
 [ { "a" "b" "c" "d" "ab" "bc" "cd" "abc" "bcd" "abcd" } ] [ "abcd" all-subseqs ] unit-test
 
 [ { "a" "ab" "abc" "abcd" "b" "bc" "bcd" "c" "cd" "d" } ]
index 92eb6ec7fc8d574c7f88d53a0bf3f8526ac5c3f3..b1196e45e0a1750b3846e080a862ed7cbc8d090f 100644 (file)
@@ -27,9 +27,6 @@ IN: sequences.extras
     [ dupd call( a -- ? ) [ 2array ] [ 2drop f ] if ] curry
     2map [ ] filter ; inline
 
-: insert-sorted ( elt seq -- seq )
-    2dup [ < ] with find drop over length or swap insert-nth ;
-
 : reduce-from ( ... seq identity quot: ( ... prev elt -- ... next ) i -- ... result )
     [ swap ] 2dip each-from ; inline
 
@@ -384,12 +381,12 @@ PRIVATE>
 : last= ( seq elt -- ? ) [ last ] dip = ; inline
 : nth= ( n seq elt -- ? ) [ nth ] dip = ; inline
 
-: first? ( seq quot -- ? ) [ first ] dip call ; inline
-: second? ( seq quot -- ? ) [ second ] dip call ; inline
-: third? ( seq quot -- ? ) [ third ] dip call ; inline
-: fourth? ( seq quot -- ? ) [ fourth ] dip call ; inline
-: last? ( seq quot -- ? ) [ last ] dip call ; inline
-: nth? ( n seq quot -- ? ) [ nth ] dip call ; inline
+: first? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? ) [ first ] dip call ; inline
+: second? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? ) [ second ] dip call ; inline
+: third? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? ) [ third ] dip call ; inline
+: fourth? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? ) [ fourth ] dip call ; inline
+: last? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? ) [ last ] dip call ; inline
+: nth? ( ... n seq quot: ( ... elt -- ... ? ) -- ... ? ) [ nth ] dip call ; inline
 
 : loop>sequence ( quot exemplar -- seq )
    [ '[ [ @ [ [ , ] when* ] keep ] loop ] ] dip make ; inline
@@ -417,10 +414,10 @@ PRIVATE>
     set-nth-unsafe ;
 
 : set-nths ( value indices seq -- )
-    swapd '[ [ _ ] dip _ set-nth ] each ; inline
+    swapd '[ _ swap _ set-nth ] each ; inline
 
 : set-nths-unsafe ( value indices seq -- )
-    swapd '[ [ _ ] dip _ set-nth-unsafe ] each ; inline
+    swapd '[ _ swap _ set-nth-unsafe ] each ; inline
 
 : flatten1 ( obj -- seq )
     [