Making all of basis and extra unambiguous for sets/namespaces
parent
7074979745
commit
6298203b4c
|
@ -3,6 +3,7 @@
|
|||
USING: accessors kernel sequences sets arrays math strings fry
|
||||
namespaces prettyprint compiler.cfg.linear-scan.live-intervals
|
||||
compiler.cfg.linear-scan.allocation compiler.cfg assocs ;
|
||||
FROM: namespaces => set ;
|
||||
IN: compiler.cfg.linear-scan.debugger
|
||||
|
||||
: check-linear-scan ( live-intervals machine-registers -- )
|
||||
|
|
|
@ -4,6 +4,7 @@ USING: sequences kernel splitting lists fry accessors assocs math.order
|
|||
math combinators namespaces urls.encoding xml.syntax xmode.code2html
|
||||
xml.data arrays strings vectors xml.writer io.streams.string locals
|
||||
unicode.categories ;
|
||||
FROM: namespaces => set ;
|
||||
IN: farkup
|
||||
|
||||
SYMBOL: relative-link-prefix
|
||||
|
|
|
@ -7,6 +7,7 @@ io.encodings.ascii io.timeouts io.sockets io.sockets.secure io.crlf
|
|||
kernel logging sequences combinators splitting assocs strings
|
||||
math.order math.parser random system calendar summary calendar.format
|
||||
accessors sets hashtables base64 debugger classes prettyprint words ;
|
||||
FROM: namespaces => set ;
|
||||
IN: smtp
|
||||
|
||||
SYMBOL: smtp-domain
|
||||
|
|
|
@ -4,6 +4,7 @@ USING: kernel namespaces xml.tokenize xml.state xml.name
|
|||
xml.data accessors arrays make xml.char-classes fry assocs sequences
|
||||
math xml.errors sets combinators io.encodings io.encodings.iana
|
||||
unicode.case xml.dtd strings xml.entities unicode.categories ;
|
||||
FROM: namespaces => set ;
|
||||
IN: xml.elements
|
||||
|
||||
: take-interpolated ( quot -- interpolated )
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
! Copyright (C) 2010 Daniel Ehrenberg
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: new-sets tools.test kernel prettyprint hash-sets sorting ;
|
||||
IN: new-sets.tests
|
||||
|
||||
[ { } ] [ { } { } intersect ] unit-test
|
||||
[ { 2 3 } ] [ { 1 2 3 } { 2 3 4 } intersect ] unit-test
|
||||
|
||||
[ { } ] [ { } { } diff ] unit-test
|
||||
[ { 1 } ] [ { 1 2 3 } { 2 3 4 } diff ] unit-test
|
||||
|
||||
[ { } ] [ { } { } union ] unit-test
|
||||
[ { 1 2 3 4 } ] [ { 1 2 3 } { 2 3 4 } union ] unit-test
|
||||
|
||||
[ t ] [ { 1 2 } { 1 3 } intersects? ] unit-test
|
||||
|
||||
[ f ] [ { 4 2 } { 1 3 } intersects? ] unit-test
|
||||
|
||||
[ f ] [ { } { 1 } intersects? ] unit-test
|
||||
|
||||
[ f ] [ { 1 } { } intersects? ] unit-test
|
||||
|
||||
[ t ] [ 4 { 2 4 5 } in? ] unit-test
|
||||
[ f ] [ 1 { 2 4 5 } in? ] unit-test
|
||||
|
||||
[ V{ 1 2 3 } ] [ 3 V{ 1 2 } clone [ adjoin ] keep ] unit-test
|
||||
[ V{ 1 2 } ] [ 2 V{ 1 2 } clone [ adjoin ] keep ] unit-test
|
||||
[ V{ 1 2 } ] [ 3 V{ 1 2 } clone [ delete ] keep ] unit-test
|
||||
[ V{ 2 } ] [ 1 V{ 1 2 } clone [ delete ] keep ] unit-test
|
||||
|
||||
[ t ] [ { 1 2 3 } { 2 1 3 } set= ] unit-test
|
||||
[ f ] [ { 2 3 } { 1 2 3 } set= ] unit-test
|
||||
[ f ] [ { 1 2 3 } { 2 3 } set= ] unit-test
|
||||
|
||||
[ { 1 } ] [ { 1 } members ] unit-test
|
||||
|
||||
[ { 1 2 3 } ] [ { 1 1 1 2 2 3 3 3 3 3 } dup set-like natural-sort ] unit-test
|
||||
[ { 1 2 3 } ] [ HS{ 1 2 3 } { } set-like natural-sort ] unit-test
|
||||
|
||||
[ HS{ 1 2 3 } ] [ { 1 2 3 } fast-set ] unit-test
|
||||
|
||||
[ { 1 2 3 } ] [ { { 1 } { 2 } { 1 3 } } combine ] unit-test
|
||||
|
||||
[ f ] [ { 0 1 1 2 3 5 } all-unique? ] unit-test
|
||||
[ t ] [ { 0 1 2 3 4 5 } all-unique? ] unit-test
|
||||
|
||||
[ { 1 2 3 } ] [ { 1 2 2 3 3 } { } set-like ] unit-test
|
||||
[ { 3 2 1 } ] [ { 3 3 2 2 1 } { } set-like ] unit-test
|
||||
|
||||
[ { 2 1 2 1 } ] [ { 1 2 3 2 1 2 1 } duplicates ] unit-test
|
||||
[ f ] [ HS{ 1 2 3 1 2 1 } duplicates ] unit-test
|
||||
|
||||
[ H{ { 3 HS{ 1 2 } } } ] [ H{ } clone 1 3 pick adjoin-at 2 3 pick adjoin-at ] unit-test
|
|
@ -1,106 +0,0 @@
|
|||
! Copyright (C) 2010 Daniel Ehrenberg
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors assocs hashtables kernel vectors
|
||||
math sequences ;
|
||||
IN: new-sets
|
||||
|
||||
! Set protocol
|
||||
MIXIN: set
|
||||
GENERIC: adjoin ( elt set -- )
|
||||
GENERIC: in? ( elt set -- ? )
|
||||
GENERIC: delete ( elt set -- )
|
||||
GENERIC: set-like ( set exemplar -- set' )
|
||||
GENERIC: fast-set ( set -- set' )
|
||||
GENERIC: members ( set -- sequence )
|
||||
GENERIC: union ( set1 set2 -- set )
|
||||
GENERIC: intersect ( set1 set2 -- set )
|
||||
GENERIC: intersects? ( set1 set2 -- ? )
|
||||
GENERIC: diff ( set1 set2 -- set )
|
||||
GENERIC: subset? ( set1 set2 -- ? )
|
||||
GENERIC: set= ( set1 set2 -- ? )
|
||||
GENERIC: duplicates ( set -- sequence )
|
||||
GENERIC: all-unique? ( set -- ? )
|
||||
|
||||
! Defaults for some methods.
|
||||
! Override them for efficiency
|
||||
|
||||
M: set union
|
||||
[ [ members ] bi@ append ] keep set-like ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
: tester ( set -- quot )
|
||||
fast-set [ in? ] curry ; inline
|
||||
|
||||
: sequence/tester ( set1 set2 -- set1' quot )
|
||||
[ members ] [ tester ] bi* ; inline
|
||||
|
||||
PRIVATE>
|
||||
|
||||
M: set intersect
|
||||
[ sequence/tester filter ] keep set-like ;
|
||||
|
||||
M: set diff
|
||||
[ sequence/tester [ not ] compose filter ] keep set-like ;
|
||||
|
||||
M: set intersects?
|
||||
sequence/tester any? ;
|
||||
|
||||
M: set subset?
|
||||
sequence/tester all? ;
|
||||
|
||||
M: set set=
|
||||
2dup subset? [ swap subset? ] [ 2drop f ] if ;
|
||||
|
||||
M: set fast-set ;
|
||||
|
||||
M: set duplicates drop f ;
|
||||
|
||||
M: set all-unique? drop t ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
: (prune) ( elt hash vec -- )
|
||||
3dup drop in? [ 3drop ] [
|
||||
[ drop adjoin ] [ nip push ] 3bi
|
||||
] if ; inline
|
||||
|
||||
: prune ( seq -- newseq )
|
||||
[ f fast-set ] [ length <vector> ] bi
|
||||
[ [ (prune) ] 2curry each ] keep ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
! Sequences are sets
|
||||
INSTANCE: sequence set
|
||||
|
||||
M: sequence in?
|
||||
member? ; inline
|
||||
|
||||
M: sequence adjoin
|
||||
[ delete ] [ push ] 2bi ;
|
||||
|
||||
M: sequence delete
|
||||
remove! drop ; inline
|
||||
|
||||
M: sequence set-like
|
||||
[ members ] dip like ;
|
||||
|
||||
M: sequence members
|
||||
[ prune ] keep like ;
|
||||
|
||||
M: sequence all-unique?
|
||||
dup prune sequence= ;
|
||||
|
||||
! Some sequence methods are defined using hash-sets
|
||||
USE: vocabs.loader
|
||||
"hash-sets" require
|
||||
|
||||
: combine ( sets -- set )
|
||||
f [ union ] reduce ;
|
||||
|
||||
: gather ( seq quot -- newseq )
|
||||
map concat members ; inline
|
||||
|
||||
: adjoin-at ( value key assoc -- )
|
||||
[ [ f fast-set ] unless* [ adjoin ] keep ] change-at ;
|
|
@ -4,6 +4,7 @@ USING: accessors arrays hashtables assocs io kernel locals math
|
|||
math.vectors math.matrices math.matrices.elimination namespaces
|
||||
parser prettyprint sequences words combinators math.parser
|
||||
splitting sorting shuffle sets math.order ;
|
||||
FROM: namespaces => set ;
|
||||
IN: koszul
|
||||
|
||||
! Utilities
|
||||
|
|
|
@ -5,6 +5,7 @@ destructors fry io io.encodings.utf8 kernel managed-server
|
|||
namespaces parser sequences sorting splitting strings.parser
|
||||
unicode.case unicode.categories calendar calendar.format
|
||||
locals io.encodings.binary io.encodings.string prettyprint ;
|
||||
FROM: namespaces => set ;
|
||||
IN: managed-server.chat
|
||||
|
||||
TUPLE: chat-server < managed-server ;
|
||||
|
|
|
@ -5,6 +5,7 @@ io.encodings.binary io.servers.connection io.sockets
|
|||
io.streams.duplex fry kernel locals math math.ranges multiline
|
||||
namespaces prettyprint random sequences sets splitting threads
|
||||
tools.continuations ;
|
||||
FROM: namespaces => set ;
|
||||
IN: managed-server
|
||||
|
||||
TUPLE: managed-server < threaded-server clients ;
|
||||
|
|
|
@ -6,6 +6,7 @@ definitions prettyprint prettyprint.backend prettyprint.custom
|
|||
quotations generalizations debugger io compiler.units
|
||||
kernel.private effects accessors hashtables sorting shuffle
|
||||
math.order sets see effects.parser ;
|
||||
FROM: namespaces => set ;
|
||||
IN: multi-methods
|
||||
|
||||
! PART I: Converting hook specializers
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
USING: assocs kernel math math.combinatorics math.functions
|
||||
math.parser math.primes namespaces project-euler.common
|
||||
sequences sets strings grouping math.ranges arrays fry math.order ;
|
||||
FROM: namespaces => set ;
|
||||
IN: project-euler.051
|
||||
<PRIVATE
|
||||
SYMBOL: family-count
|
||||
|
|
Loading…
Reference in New Issue