fry macros arrays assocs sets classes mirrors unicode.script
unicode.data ;
FROM: ascii => ascii? ;
+FROM: sets => members ;
IN: regexp.classes
SINGLETONS: dot letter-class LETTER-class Letter-class digit-class
TUPLE: class-partition integers not-integers simples not-simples and or other ;
: partition-classes ( seq -- class-partition )
- prune
+ members
[ integer? ] partition
[ not-integer? ] partition
[ simple-class? ] partition
[ t swap remove ] change-other
dup contradiction?
[ drop f ]
- [ filter-not-integers class-partition>seq prune t and-class seq>instance ] if ;
+ [ filter-not-integers class-partition>seq members t and-class seq>instance ] if ;
: <and-class> ( seq -- class )
dup and-class flatten partition-classes
[ f swap remove ] change-other
dup tautology?
[ drop t ]
- [ filter-integers class-partition>seq prune f or-class seq>instance ] if ;
+ [ filter-integers class-partition>seq members f or-class seq>instance ] if ;
: <or-class> ( seq -- class )
dup or-class flatten partition-classes
: condition-states ( condition -- states )
dup condition? [
[ yes>> ] [ no>> ] bi
- [ condition-states ] bi@ append prune
+ [ condition-states ] bi@ union
] [ 1array ] if ;
: condition-at ( condition assoc -- new-condition )
[ [ simple ] keep ] H{ } map>assoc ;
MEMO: simple-script-table ( -- table )
- script-table interval-values prune simple-table ;
+ script-table interval-values members simple-table ;
MEMO: simple-category-table ( -- table )
categories simple-table ;
dup class? [ dup seeing-implementors % ] when
dup generic? [ dup seeing-methods % ] when
drop
- ] { } make prune ;
+ ] { } make members ;
: see-methods ( word -- )
methods see-all nl ;
] { } make <interval-map> ;
: process-interval-file ( ranges -- table )
- dup values prune interned
+ dup values members interned
[ expand-ranges ] with-variable ;
: load-interval-file ( filename -- table )
: query ( begin suffix-array -- matches )
2dup find-index dup
- [ -rot [ from-to ] keep <funky-slice> [ seq>> ] map prune ]
+ [ -rot [ from-to ] keep <funky-slice> [ seq>> ] map members ]
[ 3drop { } ] if ;
QUALIFIED: vocabs
FROM: alien.libraries.private => >deployed-library-path ;
FROM: namespaces => set ;
+FROM: sets => members ;
IN: tools.deploy.shaker
! This file is some hairy shit.
: write-vocab-manifest ( vocab-manifest-out -- )
"Writing vocabulary manifest to " write dup print flush
vocabs "VOCABS:" prefix
- deploy-libraries get [ libraries get at path>> ] map prune "LIBRARIES:" prefix append
+ deploy-libraries get [ libraries get at path>> ] map members "LIBRARIES:" prefix append
swap utf8 set-file-lines ;
: prepare-deploy-libraries ( -- )
combinators sorting math.parser vocabs definitions
tools.profiler.private tools.crossref continuations generic
compiler.units compiler.crossref sets classes fry ;
+FROM: sets => members ;
IN: tools.profiler
: profile ( quot -- )
[ smart-usage [ word? ] filter ]
[ generic-call-sites-of keys ]
[ effect-dependencies-of keys ]
- tri 3append prune ;
+ tri 3append members ;
: usage-counters ( word -- alist )
profiler-usage counters ;
sets columns fry deques ui.gadgets ui.gadgets.private ascii
combinators.short-circuit ;
FROM: namespaces => set ;
+FROM: sets => members ;
IN: ui.gestures
: get-gesture-handler ( gesture gadget -- quot )
: modifier ( mod modifiers -- seq )
[ second swap bitand 0 > ] with filter
- 0 <column> prune [ f ] [ >array ] if-empty ;
+ 0 <column> members [ f ] [ >array ] if-empty ;
: drag-loc ( -- loc )
hand-loc get-global hand-click-loc get-global v- ;
layout-queue [
dup layout find-world [ , ] when*
] slurp-deque
- ] { } make prune ;
+ ] { } make members ;
: redraw-worlds ( seq -- )
[ dup update-hand draw-world ] each ;
] assoc-map ;
: properties>intervals ( properties -- assoc[str,interval] )
- dup values prune [ f ] H{ } map>assoc
+ dup values members [ f ] H{ } map>assoc
[ [ push-at ] curry assoc-each ] keep
[ <interval-set> ] assoc-map ;
dup vocab-tags-path set-vocab-file-contents ;
: add-vocab-tags ( tags vocab -- )
- [ vocab-tags append prune ] keep set-vocab-tags ;
+ [ vocab-tags append members ] keep set-vocab-tags ;
: remove-vocab-tags ( tags vocab -- )
[ vocab-tags swap diff ] keep set-vocab-tags ;
: monitor-thread ( -- )\r
[\r
[\r
- vocab-roots get prune [ add-monitor-for-path ] each\r
+ vocab-roots get [ add-monitor-for-path ] each\r
\r
H{ } clone changed-vocabs set-global\r
vocabs [ changed-vocab ] each\r
[ [ vocab f >>docs-loaded? drop ] each ] bi*
]
[
- append prune
+ union
[ unchanged-vocabs ]
[ require-all load-failures. ] bi
] 2bi ;
assoc>> >alist ;
: (keyword-map-no-word-sep) ( assoc -- str )
- keys concat [ alpha? not ] filter prune natural-sort ;
+ keys combine [ alpha? not ] filter natural-sort ;
: keyword-map-no-word-sep* ( keyword-map -- str )
dup no-word-sep>> [ ] [
sequences arrays vectors assocs namespaces words sorting layouts
math hashtables kernel.private sets math.order ;
FROM: classes => members ;
+RENAME: members sets => set-members
IN: classes.algebra
<PRIVATE
TUPLE: anonymous-union { members read-only } ;
: <anonymous-union> ( members -- class )
- [ null eq? not ] filter prune
+ [ null eq? not ] filter set-members
dup length 1 = [ first ] [ anonymous-union boa ] if ;
TUPLE: anonymous-intersection { participants read-only } ;
: <anonymous-intersection> ( participants -- class )
- prune dup length 1 = [ first ] [ anonymous-intersection boa ] if ;
+ set-members dup length 1 =
+ [ first ] [ anonymous-intersection boa ] if ;
TUPLE: anonymous-complement { class read-only } ;
! Temporarily for compatibility
-ALIAS: prune members
: unique ( seq -- assoc )
[ dup ] H{ } map>assoc ;
: conjoin ( elt assoc -- )
] with-directory ;
: patch-counts ( authors -- assoc )
- dup prune
+ dup members
[ dup rot [ = ] with count ] with
{ } map>assoc ;
[ word? ] filter [ word>xref ] map ;
: filter-prefix ( seq prefix -- seq )
- [ drop-prefix nip length 0 = ] curry filter prune ;
+ [ drop-prefix nip length 0 = ] curry filter members ;
MEMO: (vocab-words) ( name -- seq )
>vocab-link words [ name>> ] map ;
append H{ } [ assoc-union ] reduce keys ;
: vocabs-words ( names -- seq )
- prune [ (vocab-words) ] map concat ;
+ members [ (vocab-words) ] map concat ;
PRIVATE>
[ >url ] map ;
: find-all-links ( vector -- vector' )
- [ find-hrefs ] [ find-frame-links ] bi append prune ;
+ [ find-hrefs ] [ find-frame-links ] bi union ;
: find-forms ( vector -- vector' )
"form" over find-opening-tags-by-name
[ nth ] 2keep swap 1 + tail-slice (inversions) +
] curry each ;
-: duplicates? ( seq -- ? )
- dup prune [ length ] bi@ > ;
-
: (wedge) ( n basis1 basis2 -- n basis )
- append dup duplicates? [
+ append dup all-unique? not [
2drop 0 { }
] [
dup permutation inversions -1^ rot *
:: do-step ( errors summary-file details-file -- )
errors
[ error-type +linkage-error+ eq? not ] filter
- [ file>> ] map prune natural-sort summary-file to-file
+ [ file>> ] map members natural-sort summary-file to-file
errors details-file utf8 [ errors. ] with-file-writer ;
: do-tests ( -- )
"" to-refresh drop 2dup [ empty? not ] either?
[
"Boot image is out of date. Changed vocabs:" print
- append prune [ print ] each
+ members [ print ] each
flush
1 exit
] [ 2drop ] if ;
PRIVATE>
: euler004 ( -- answer )
- source-004 dup [ * ] cartesian-map concat prune max-palindrome ;
+ source-004 dup [ * ] cartesian-map combine max-palindrome ;
! [ euler004 ] 100 ave-time
! 1164 ms ave run time - 39.35 SD (100 trials)
! --------
: euler029 ( -- answer )
- 2 100 [a,b] dup [ ^ ] cartesian-map concat prune length ;
+ 2 100 [a,b] dup [ ^ ] cartesian-map concat members length ;
! [ euler029 ] 100 ave-time
! 704 ms ave run time - 28.07 SD (100 trials)
PRIVATE>
: euler032 ( -- answer )
- source-032 [ valid? ] filter products prune sum ;
+ source-032 [ valid? ] filter products members sum ;
! [ euler032 ] 10 ave-time
! 16361 ms ave run time - 417.8 SD (10 trials)
50 [1,b] 2000 [1,b]
[ mmp ] cartesian-map concat
[ pandigital? ] filter
- products prune sum ;
+ products members sum ;
! [ euler032a ] 10 ave-time
! 2624 ms ave run time - 131.91 SD (10 trials)
over length <rollover> swap [ bitxor ] 2map ;
: frequency-analysis ( seq -- seq )
- dup prune [
+ dup members [
[ 2dup [ = ] curry count 2array , ] each
] { } make nip ; inline
] { } make ;
: find-source ( seq -- elt )
- unzip diff prune
+ unzip diff
[ "Topological sort failed" throw ] [ first ] if-empty ;
: remove-source ( seq elt -- seq )
: topological-sort ( seq -- seq )
[ [ (topological-sort) ] { } make ] keep
- concat prune over diff append ;
+ combine over diff append ;
: euler079 ( -- answer )
source-079 >edges topological-sort 10 digits>integer ;
! [ euler079 ] 100 ave-time
! 1 ms ave run time - 0.46 SD (100 trials)
-! TODO: prune and diff are relatively slow; topological sort could be
+! TODO: set words on sequences are relatively slow; topological sort could be
! cleaned up and generalized much better, but it works for this problem
SOLUTION: euler079
[ 0 prefix ] [ 0 suffix ] bi [ + ] 2map ;
: generate ( n -- seq )
- 1 - { 1 } [ (generate) ] iterate concat prune ;
+ 1 - { 1 } [ (generate) ] iterate combine ;
: squarefree ( n -- ? )
factors all-unique? ;
nonmatching>> push-links ;
: filter-base-links ( spider spider-result -- base-links nonmatching-links )
- [ base>> host>> ] [ links>> prune ] bi*
+ [ base>> host>> ] [ links>> members ] bi*
[ host>> = ] with partition ;
: add-spidered ( spider spider-result -- )