From b5eae48068384ff8fd53b5d6f4d268668c6d9c9a Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Wed, 8 Jan 2014 11:50:35 -0800 Subject: [PATCH] sequences.extras: remove insert-sorted (can use versions in sorting.extras instead). --- extra/sequences/extras/extras-tests.factor | 6 ------ extra/sequences/extras/extras.factor | 19 ++++++++----------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/extra/sequences/extras/extras-tests.factor b/extra/sequences/extras/extras-tests.factor index aaa405219e..abd15a7b62 100644 --- a/extra/sequences/extras/extras-tests.factor +++ b/extra/sequences/extras/extras-tests.factor @@ -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" } ] diff --git a/extra/sequences/extras/extras.factor b/extra/sequences/extras/extras.factor index 92eb6ec7fc..b1196e45e0 100644 --- a/extra/sequences/extras/extras.factor +++ b/extra/sequences/extras/extras.factor @@ -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 ) [