write a replace word and 2seq>assoc
parent
c4b5e783db
commit
d6fb777e50
|
@ -1,4 +1,4 @@
|
|||
USING: assocs kernel vectors sequences namespaces ;
|
||||
USING: arrays assocs kernel vectors sequences namespaces ;
|
||||
IN: assocs.lib
|
||||
|
||||
: >set ( seq -- hash )
|
||||
|
@ -35,3 +35,6 @@ IN: assocs.lib
|
|||
[ with each ] curry assoc-each ; inline
|
||||
|
||||
: insert ( value variable -- ) namespace insert-at ;
|
||||
|
||||
: 2seq>assoc ( keys values exemplar -- assoc )
|
||||
>r 2array flip r> assoc-like ;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: combinators.lib kernel sequences math namespaces assocs
|
||||
random sequences.private shuffle math.functions mirrors
|
||||
arrays math.parser math.private sorting strings ascii macros ;
|
||||
arrays math.parser math.private sorting strings ascii macros
|
||||
assocs.lib ;
|
||||
IN: sequences.lib
|
||||
|
||||
: each-withn ( seq quot n -- ) nwith each ; inline
|
||||
|
@ -220,3 +221,6 @@ PRIVATE>
|
|||
|
||||
: nths ( indices seq -- seq' )
|
||||
[ swap nth ] with map ;
|
||||
|
||||
: replace ( str oldseq newseq -- str' )
|
||||
H{ } 2seq>assoc [ dupd at* [ nip ] [ drop ] if ] curry map ;
|
||||
|
|
Loading…
Reference in New Issue