extra sequences functions moved out of core
parent
48c63c5efb
commit
6132608cc2
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2005, 2009 Slava Pestov, Daniel Ehrenberg.
|
! Copyright (C) 2005, 2009 Slava Pestov, Daniel Ehrenberg.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors kernel kernel.private locals slots.private math
|
USING: accessors kernel kernel.private slots.private math
|
||||||
math.private math.order ;
|
math.private math.order ;
|
||||||
IN: sequences
|
IN: sequences
|
||||||
|
|
||||||
|
@ -358,8 +358,14 @@ PRIVATE>
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
|
: ((each)) ( seq -- n quot )
|
||||||
|
[ length ] keep [ nth-unsafe ] curry ; inline
|
||||||
|
|
||||||
: (each) ( seq quot -- n quot' )
|
: (each) ( seq quot -- n quot' )
|
||||||
[ [ length ] keep [ nth-unsafe ] curry ] dip compose ; inline
|
[ ((each)) ] dip compose ; inline
|
||||||
|
|
||||||
|
: (each-index) ( seq quot -- n quot' )
|
||||||
|
[ ((each)) [ keep ] curry ] dip compose ; inline
|
||||||
|
|
||||||
: (collect) ( quot into -- quot' )
|
: (collect) ( quot into -- quot' )
|
||||||
[ [ keep ] dip set-nth-unsafe ] 2curry ; inline
|
[ [ keep ] dip set-nth-unsafe ] 2curry ; inline
|
||||||
|
@ -498,19 +504,18 @@ PRIVATE>
|
||||||
: follow ( obj quot -- seq )
|
: follow ( obj quot -- seq )
|
||||||
[ dup ] swap [ keep ] curry produce nip ; inline
|
[ dup ] swap [ keep ] curry produce nip ; inline
|
||||||
|
|
||||||
: prepare-index ( seq quot -- seq n quot )
|
|
||||||
[ dup length ] dip ; inline
|
|
||||||
|
|
||||||
: each-index ( seq quot -- )
|
: each-index ( seq quot -- )
|
||||||
prepare-index 2each ; inline
|
(each-index) each-integer ; inline
|
||||||
|
|
||||||
: interleave ( seq between quot -- )
|
: interleave ( seq between quot -- )
|
||||||
swap [ drop ] [ [ 2dip call ] 2curry ] 2bi
|
pick empty? [ 3drop ] [
|
||||||
[ [ 0 = ] 2dip if ] 2curry
|
[ [ drop first-unsafe ] dip call ]
|
||||||
each-index ; inline
|
[ [ rest-slice ] 2dip [ bi* ] 2curry each ]
|
||||||
|
3bi
|
||||||
|
] if ; inline
|
||||||
|
|
||||||
: map-index ( seq quot -- newseq )
|
: map-index ( seq quot -- newseq )
|
||||||
prepare-index 2map ; inline
|
[ dup length iota ] dip 2map ; inline
|
||||||
|
|
||||||
: reduce-index ( seq identity quot -- )
|
: reduce-index ( seq identity quot -- )
|
||||||
swapd each-index ; inline
|
swapd each-index ; inline
|
||||||
|
@ -931,17 +936,3 @@ PRIVATE>
|
||||||
[ array-flip ] [ generic-flip ] if
|
[ array-flip ] [ generic-flip ] if
|
||||||
] [ generic-flip ] if
|
] [ generic-flip ] if
|
||||||
] unless ;
|
] unless ;
|
||||||
|
|
||||||
: reduce1 ( seq quot -- result ) [ unclip ] dip reduce ; inline
|
|
||||||
|
|
||||||
:: reduce-r
|
|
||||||
( list identity quot: ( obj1 obj2 -- obj ) -- result )
|
|
||||||
list empty?
|
|
||||||
[ identity ]
|
|
||||||
[ list rest identity quot reduce-r list first quot call ] if ;
|
|
||||||
inline recursive
|
|
||||||
|
|
||||||
:: combos ( list1 list2 -- result ) list2 [ [ 2array ] curry list1 swap map ] map concat ;
|
|
||||||
: (head-slice) ( seq n -- seq' ) over length over < [ drop ] [ head-slice ] if ;
|
|
||||||
: find-all ( seq quot -- elts ) [ [ length iota ] keep ] dip
|
|
||||||
[ dupd call( a -- ? ) [ 2array ] [ 2drop f ] if ] curry 2map [ ] filter ; inline
|
|
|
@ -6,7 +6,7 @@ sets strings vocabs sorting accessors arrays compiler.units
|
||||||
combinators vectors splitting continuations math
|
combinators vectors splitting continuations math
|
||||||
parser.notes ;
|
parser.notes ;
|
||||||
IN: vocabs.parser
|
IN: vocabs.parser
|
||||||
|
|
||||||
ERROR: no-word-error name ;
|
ERROR: no-word-error name ;
|
||||||
|
|
||||||
: word-restarts ( possibilities -- restarts )
|
: word-restarts ( possibilities -- restarts )
|
||||||
|
@ -17,7 +17,7 @@ ERROR: no-word-error name ;
|
||||||
word-restarts
|
word-restarts
|
||||||
swap "Defer word in current vocabulary" swap 2array
|
swap "Defer word in current vocabulary" swap 2array
|
||||||
suffix ;
|
suffix ;
|
||||||
|
|
||||||
: <no-word-error> ( name possibilities -- error restarts )
|
: <no-word-error> ( name possibilities -- error restarts )
|
||||||
[ drop \ no-word-error boa ] [ word-restarts-with-defer ] 2bi ;
|
[ drop \ no-word-error boa ] [ word-restarts-with-defer ] 2bi ;
|
||||||
|
|
||||||
|
@ -198,4 +198,4 @@ PRIVATE>
|
||||||
2dup qualified-search dup [ 2nip ] [ drop vocab-search ] if ;
|
2dup qualified-search dup [ 2nip ] [ drop vocab-search ] if ;
|
||||||
|
|
||||||
: search ( name -- word/f )
|
: search ( name -- word/f )
|
||||||
manifest get search-manifest ;
|
manifest get search-manifest ;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
USING: accessors arrays delegate delegate.protocols
|
USING: accessors arrays delegate delegate.protocols
|
||||||
io.pathnames kernel locals sequences
|
io.pathnames kernel locals sequences
|
||||||
vectors make strings ui.frp.signals ui.frp.gadgets ;
|
vectors make strings ui.frp.signals ui.frp.gadgets
|
||||||
|
sequences.extras ;
|
||||||
IN: file-trees
|
IN: file-trees
|
||||||
|
|
||||||
TUPLE: walkable-vector vector father ;
|
TUPLE: walkable-vector vector father ;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
USING: arrays vectors combinators effects kernel math sequences splitting
|
USING: arrays vectors combinators effects kernel math sequences splitting
|
||||||
strings.parser parser fry ;
|
strings.parser parser fry sequences.extras ;
|
||||||
IN: fries
|
IN: fries
|
||||||
: str-fry ( str on -- quot ) split
|
: str-fry ( str on -- quot ) split
|
||||||
[ unclip-last [ [ spin glue ] reduce-r ] 2curry ]
|
[ unclip-last [ [ spin glue ] reduce-r ] 2curry ]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
USING: accessors arrays db.tuples db.sqlite persistency db.queries
|
USING: accessors arrays db.tuples db.sqlite persistency db.queries
|
||||||
io.files.temp kernel monads sequences ui ui.frp.gadgets
|
io.files.temp kernel monads sequences ui ui.frp.gadgets
|
||||||
ui.frp.layout ui.frp.signals ui.gadgets.scrollers ui.gadgets.labels
|
ui.frp.layout ui.frp.signals ui.gadgets.scrollers ui.gadgets.labels
|
||||||
colors.constants ui.pens.solid combinators math locals strings fries
|
colors.constants ui.pens.solid combinators math locals strings
|
||||||
ui.images db.types ;
|
ui.images db.types ;
|
||||||
FROM: sets => prune ;
|
FROM: sets => prune ;
|
||||||
IN: recipes
|
IN: recipes
|
||||||
|
@ -11,7 +11,7 @@ STORED-TUPLE: recipe { title { VARCHAR 100 } } { votes INTEGER } { txt TEXT } {
|
||||||
: top-recipes ( offset search -- recipes ) <query> T{ recipe } rot >>title >>tuple
|
: top-recipes ( offset search -- recipes ) <query> T{ recipe } rot >>title >>tuple
|
||||||
"votes" >>order 30 >>limit swap >>offset get-tuples ;
|
"votes" >>order 30 >>limit swap >>offset get-tuples ;
|
||||||
: top-genres ( -- genres ) f f top-recipes [ genre>> ] map prune 4 (head-slice) ;
|
: top-genres ( -- genres ) f f top-recipes [ genre>> ] map prune 4 (head-slice) ;
|
||||||
: <image-button> ( str -- button ) i" vocab:recipes/icons/_.tiff" <image-name> <frp-button> ;
|
: <image-button> ( str -- button ) "vocab:recipes/icons/" ".tiff" surround <image-name> <frp-button> ;
|
||||||
|
|
||||||
: interface ( -- book ) [
|
: interface ( -- book ) [
|
||||||
[
|
[
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
USING: fry functors generalizations kernel macros peg peg-lexer
|
USING: fry functors generalizations kernel macros peg peg-lexer
|
||||||
sequences ;
|
sequences sequences.extras ;
|
||||||
FROM: ui.frp.signals => #1 ;
|
FROM: ui.frp.signals => #1 ;
|
||||||
IN: ui.frp.functors
|
IN: ui.frp.functors
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,9 @@ IN: ui.frp.gadgets
|
||||||
|
|
||||||
TUPLE: frp-button < button hook value ;
|
TUPLE: frp-button < button hook value ;
|
||||||
: <frp-button> ( gadget -- button ) [
|
: <frp-button> ( gadget -- button ) [
|
||||||
|
[ dup hook>> [ call( button -- ) ] [ drop ] if* ]
|
||||||
[ [ [ value>> ] [ ] bi or ] keep set-control-value ]
|
[ [ [ value>> ] [ ] bi or ] keep set-control-value ]
|
||||||
[ dup hook>> [ call( button -- ) ] [ drop ] if* ] bi
|
[ model>> f swap (>>value) ] tri
|
||||||
] frp-button new-button f <basic> >>model ;
|
] frp-button new-button f <basic> >>model ;
|
||||||
: <frp-border-button> ( text -- button ) <frp-button> border-button-theme ;
|
: <frp-border-button> ( text -- button ) <frp-button> border-button-theme ;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
USING: accessors arrays kernel monads models models.product sequences classes ;
|
USING: accessors arrays kernel monads models models.product sequences classes
|
||||||
|
sequences.extras ;
|
||||||
FROM: models.product => product ;
|
FROM: models.product => product ;
|
||||||
IN: ui.frp.signals
|
IN: ui.frp.signals
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue