sequences: moving some words to sequences.extras.
parent
7d2ad13830
commit
5c225fa09f
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ;
|
||||
|
|
Loading…
Reference in New Issue