[ [ 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
! 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
! 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
] unless utf8 file-lines ;
: ordered-word? ( word -- ? )
- >lower 2 <clumps> [ first2 <= ] all? ;
+ >lower [ <= ] monotonic? ;
: ordered-words-main ( -- )
word-list [ ordered-word? ] filter
: 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 ;