]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences: moving some words to sequences.extras.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 10 Apr 2013 17:49:29 +0000 (10:49 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 10 Apr 2013 17:49:29 +0000 (10:49 -0700)
core/sequences/sequences.factor
extra/anagrams/anagrams.factor
extra/rosetta-code/ordered-words/ordered-words.factor
extra/sequences/extras/extras.factor

index 1d3b12fa75768a5ddc85574aa6688ba6f93ace5f..f209adfa6f4f6d15f1abc3df2d37699b7a984cfd 100644 (file)
@@ -1043,16 +1043,10 @@ M: object sum 0 [ + ] binary-reduce ; inline
         [ [ 2drop ] 2dip ] [ 2drop ] if
     ] curry 1 each-from drop ; inline
 
-: filter-length ( seq n -- seq' ) swap [ length = ] with filter ;
-
 : shortest ( seqs -- elt ) [ length ] infimum-by ;
 
 : longest ( seqs -- elt ) [ length ] supremum-by ;
 
-: all-shortest ( seqs -- seqs' ) dup shortest length filter-length ;
-
-: all-longest ( seqs -- seqs' ) dup longest length filter-length ;
-
 ! We hand-optimize flip to such a degree because type hints
 ! cannot express that an array is an array of arrays yet, and
 ! this word happens to be performance-critical since the compiler
index b5374ed965469e6d2f2e76dc9b19077e045ee980..7150fa8b28546e757b02d4afb7fe72354a040d80 100644 (file)
@@ -1,9 +1,8 @@
 ! Copyright (C) 2010 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: arrays ascii assocs fry io.encodings.ascii io.files
-kernel math math.order memoize sequences sorting
-math.statistics ;
+USING: ascii assocs fry io.encodings.ascii io.files kernel math
+math.statistics memoize sequences sequences.extras sorting ;
 FROM: sets => members ;
 IN: anagrams
 
index e0ca3cd14057d618bf704dffc035cb270ebcea18..63ecdb87a8d53307ec2f10b677d82b485d1c3319 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (c) 2012 Anonymous
 ! See http://factorcode.org/license.txt for BSD license.
-USING: fry grouping http.client io io.encodings.utf8 io.files
-io.files.temp kernel math math.order memoize sequences
+USING: grouping http.client io io.encodings.utf8 io.files
+io.files.temp kernel math memoize sequences sequences.extras
 unicode.case urls ;
 IN: rosetta-code.ordered-words
 
@@ -24,7 +24,7 @@ MEMO: word-list ( -- seq )
     ] unless utf8 file-lines ;
 
 : ordered-word? ( word -- ? )
-    >lower 2 <clumps> [ first2 <= ] all? ;
+    >lower [ <= ] monotonic? ;
 
 : ordered-words-main ( -- )
     word-list [ ordered-word? ] filter
index 803c0e5bd9eba4e126c2a049b8bdb1eb535f5c67..e28a6977c0552cc045ad3cc9671af414db371785 100644 (file)
@@ -390,3 +390,9 @@ PRIVATE>
 
 : map-find-index ( ... seq quot: ( ... elt index -- ... result/f ) -- ... result elt index )
     [ find-index ] (map-find-index) ; inline
+
+: filter-length ( seq n -- seq' ) swap [ length = ] with filter ;
+
+: all-shortest ( seqs -- seqs' ) dup shortest length filter-length ;
+
+: all-longest ( seqs -- seqs' ) dup longest length filter-length ;