Moving new-sets to sets
parent
a72e2cc96c
commit
7074979745
|
@ -1,4 +1,4 @@
|
||||||
USING: bit-sets tools.test new-sets kernel bit-arrays ;
|
USING: bit-sets tools.test sets kernel bit-arrays ;
|
||||||
IN: bit-sets.tests
|
IN: bit-sets.tests
|
||||||
|
|
||||||
[ T{ bit-set f ?{ t f t f t f } } ] [
|
[ T{ bit-set f ?{ t f t f t f } } ] [
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2009 Slava Pestov.
|
! Copyright (C) 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel accessors sequences byte-arrays bit-arrays math hints new-sets ;
|
USING: kernel accessors sequences byte-arrays bit-arrays math hints sets ;
|
||||||
IN: bit-sets
|
IN: bit-sets
|
||||||
|
|
||||||
TUPLE: bit-set { table bit-array read-only } ;
|
TUPLE: bit-set { table bit-array read-only } ;
|
||||||
|
|
|
@ -12,6 +12,7 @@ compiler.cfg.registers
|
||||||
compiler.cfg.comparisons
|
compiler.cfg.comparisons
|
||||||
compiler.cfg.instructions
|
compiler.cfg.instructions
|
||||||
compiler.cfg.representations.preferred ;
|
compiler.cfg.representations.preferred ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.alias-analysis
|
IN: compiler.cfg.alias-analysis
|
||||||
|
|
||||||
! We try to eliminate redundant slot operations using some simple heuristics.
|
! We try to eliminate redundant slot operations using some simple heuristics.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors assocs kernel namespaces sequences
|
USING: accessors assocs kernel namespaces sequences
|
||||||
compiler.cfg.instructions compiler.cfg.def-use
|
compiler.cfg.instructions compiler.cfg.def-use
|
||||||
compiler.cfg.rpo compiler.cfg.predecessors hash-sets new-sets ;
|
compiler.cfg.rpo compiler.cfg.predecessors hash-sets sets ;
|
||||||
FROM: namespaces => set ;
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.dce
|
IN: compiler.cfg.dce
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ compiler.units fry generalizations generic kernel locals
|
||||||
namespaces quotations sequences sets slots words
|
namespaces quotations sequences sets slots words
|
||||||
compiler.cfg.instructions compiler.cfg.instructions.syntax
|
compiler.cfg.instructions compiler.cfg.instructions.syntax
|
||||||
compiler.cfg.rpo ;
|
compiler.cfg.rpo ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.def-use
|
IN: compiler.cfg.def-use
|
||||||
|
|
||||||
GENERIC: defs-vreg ( insn -- vreg/f )
|
GENERIC: defs-vreg ( insn -- vreg/f )
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
USING: accessors assocs combinators sets math fry kernel math.order
|
USING: accessors assocs combinators sets math fry kernel math.order
|
||||||
dlists deques vectors namespaces sequences sorting locals
|
dlists deques vectors namespaces sequences sorting locals
|
||||||
compiler.cfg.rpo compiler.cfg.predecessors ;
|
compiler.cfg.rpo compiler.cfg.predecessors ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.dominance
|
IN: compiler.cfg.dominance
|
||||||
|
|
||||||
! Reference:
|
! Reference:
|
||||||
|
|
|
@ -13,6 +13,7 @@ compiler.cfg.linearization.order
|
||||||
compiler.cfg.linear-scan.allocation
|
compiler.cfg.linear-scan.allocation
|
||||||
compiler.cfg.linear-scan.allocation.state
|
compiler.cfg.linear-scan.allocation.state
|
||||||
compiler.cfg.linear-scan.live-intervals ;
|
compiler.cfg.linear-scan.live-intervals ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.linear-scan.assignment
|
IN: compiler.cfg.linear-scan.assignment
|
||||||
|
|
||||||
! This contains both active and inactive intervals; any interval
|
! This contains both active and inactive intervals; any interval
|
||||||
|
|
|
@ -4,7 +4,7 @@ USING: accessors assocs deques dlists kernel make sorting
|
||||||
namespaces sequences combinators combinators.short-circuit
|
namespaces sequences combinators combinators.short-circuit
|
||||||
fry math compiler.cfg.rpo compiler.cfg.utilities
|
fry math compiler.cfg.rpo compiler.cfg.utilities
|
||||||
compiler.cfg.loop-detection compiler.cfg.predecessors
|
compiler.cfg.loop-detection compiler.cfg.predecessors
|
||||||
new-sets hash-sets ;
|
sets hash-sets ;
|
||||||
FROM: namespaces => set ;
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.linearization.order
|
IN: compiler.cfg.linearization.order
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ USING: kernel namespaces deques accessors sets sequences assocs fry
|
||||||
hashtables dlists compiler.cfg.def-use compiler.cfg.instructions
|
hashtables dlists compiler.cfg.def-use compiler.cfg.instructions
|
||||||
compiler.cfg.rpo compiler.cfg.liveness compiler.cfg.utilities
|
compiler.cfg.rpo compiler.cfg.liveness compiler.cfg.utilities
|
||||||
compiler.cfg.predecessors ;
|
compiler.cfg.predecessors ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.liveness.ssa
|
IN: compiler.cfg.liveness.ssa
|
||||||
|
|
||||||
! TODO: merge with compiler.cfg.liveness
|
! TODO: merge with compiler.cfg.liveness
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors assocs combinators deques dlists fry kernel
|
USING: accessors assocs combinators deques dlists fry kernel
|
||||||
namespaces sequences sets compiler.cfg compiler.cfg.predecessors ;
|
namespaces sequences sets compiler.cfg compiler.cfg.predecessors ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.loop-detection
|
IN: compiler.cfg.loop-detection
|
||||||
|
|
||||||
TUPLE: natural-loop header index ends blocks ;
|
TUPLE: natural-loop header index ends blocks ;
|
||||||
|
|
|
@ -5,6 +5,7 @@ words sets combinators generalizations cpu.architecture compiler.units
|
||||||
compiler.cfg.utilities compiler.cfg compiler.cfg.rpo
|
compiler.cfg.utilities compiler.cfg compiler.cfg.rpo
|
||||||
compiler.cfg.instructions compiler.cfg.def-use ;
|
compiler.cfg.instructions compiler.cfg.def-use ;
|
||||||
FROM: compiler.cfg.instructions.syntax => insn-def-slot insn-use-slots insn-temp-slots scalar-rep ;
|
FROM: compiler.cfg.instructions.syntax => insn-def-slot insn-use-slots insn-temp-slots scalar-rep ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.representations.preferred
|
IN: compiler.cfg.representations.preferred
|
||||||
|
|
||||||
GENERIC: defs-vreg-rep ( insn -- rep/f )
|
GENERIC: defs-vreg-rep ( insn -- rep/f )
|
||||||
|
|
|
@ -15,6 +15,7 @@ compiler.cfg.utilities
|
||||||
compiler.cfg.loop-detection
|
compiler.cfg.loop-detection
|
||||||
compiler.cfg.renaming.functor
|
compiler.cfg.renaming.functor
|
||||||
compiler.cfg.representations.preferred ;
|
compiler.cfg.representations.preferred ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.representations
|
IN: compiler.cfg.representations
|
||||||
|
|
||||||
! Virtual register representation selection.
|
! Virtual register representation selection.
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel accessors namespaces make math sequences sets
|
USING: kernel accessors namespaces make math sequences sets
|
||||||
assocs fry compiler.cfg compiler.cfg.instructions ;
|
assocs fry compiler.cfg compiler.cfg.instructions ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.rpo
|
IN: compiler.cfg.rpo
|
||||||
|
|
||||||
SYMBOL: visited
|
SYMBOL: visited
|
||||||
|
|
|
@ -12,6 +12,7 @@ compiler.cfg.instructions
|
||||||
compiler.cfg.renaming
|
compiler.cfg.renaming
|
||||||
compiler.cfg.renaming.functor
|
compiler.cfg.renaming.functor
|
||||||
compiler.cfg.ssa.construction.tdmsc ;
|
compiler.cfg.ssa.construction.tdmsc ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.ssa.construction
|
IN: compiler.cfg.ssa.construction
|
||||||
|
|
||||||
! The phi placement algorithm is implemented in
|
! The phi placement algorithm is implemented in
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2009 Slava Pestov.
|
! Copyright (C) 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors arrays assocs bit-arrays bit-sets fry
|
USING: accessors arrays assocs bit-arrays bit-sets fry
|
||||||
hashtables hints kernel locals math namespaces sequences new-sets
|
hashtables hints kernel locals math namespaces sequences sets
|
||||||
compiler.cfg compiler.cfg.dominance compiler.cfg.rpo ;
|
compiler.cfg compiler.cfg.dominance compiler.cfg.rpo ;
|
||||||
FROM: namespaces => set ;
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.ssa.construction.tdmsc
|
IN: compiler.cfg.ssa.construction.tdmsc
|
||||||
|
|
|
@ -15,6 +15,7 @@ compiler.cfg.ssa.interference
|
||||||
compiler.cfg.ssa.interference.live-ranges
|
compiler.cfg.ssa.interference.live-ranges
|
||||||
compiler.cfg.utilities
|
compiler.cfg.utilities
|
||||||
compiler.utilities ;
|
compiler.utilities ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.ssa.destruction
|
IN: compiler.cfg.ssa.destruction
|
||||||
|
|
||||||
! Maps vregs to leaders.
|
! Maps vregs to leaders.
|
||||||
|
|
|
@ -6,6 +6,7 @@ compiler.cfg.rpo
|
||||||
compiler.cfg.dominance
|
compiler.cfg.dominance
|
||||||
compiler.cfg.def-use
|
compiler.cfg.def-use
|
||||||
compiler.cfg.instructions ;
|
compiler.cfg.instructions ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.ssa.liveness
|
IN: compiler.cfg.ssa.liveness
|
||||||
|
|
||||||
! Liveness checking on SSA IR, as described in
|
! Liveness checking on SSA IR, as described in
|
||||||
|
|
|
@ -8,6 +8,7 @@ compiler.cfg.instructions
|
||||||
compiler.cfg.registers
|
compiler.cfg.registers
|
||||||
compiler.cfg.stacks.height
|
compiler.cfg.stacks.height
|
||||||
compiler.cfg.parallel-copy ;
|
compiler.cfg.parallel-copy ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.stacks.local
|
IN: compiler.cfg.stacks.local
|
||||||
|
|
||||||
! Local stack analysis. We build three sets for every basic block
|
! Local stack analysis. We build three sets for every basic block
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
USING: accessors assocs combinators.short-circuit
|
USING: accessors assocs combinators.short-circuit
|
||||||
compiler.cfg.instructions compiler.cfg.rpo kernel namespaces
|
compiler.cfg.instructions compiler.cfg.rpo kernel namespaces
|
||||||
sequences sets ;
|
sequences sets ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.cfg.write-barrier
|
IN: compiler.cfg.write-barrier
|
||||||
|
|
||||||
SYMBOL: fresh-allocations
|
SYMBOL: fresh-allocations
|
||||||
|
|
|
@ -16,6 +16,7 @@ compiler.cfg.registers
|
||||||
compiler.cfg.builder
|
compiler.cfg.builder
|
||||||
compiler.codegen.fixup
|
compiler.codegen.fixup
|
||||||
compiler.utilities ;
|
compiler.utilities ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.codegen
|
IN: compiler.codegen
|
||||||
|
|
||||||
SYMBOL: insn-counts
|
SYMBOL: insn-counts
|
||||||
|
|
|
@ -7,6 +7,7 @@ compiler.tree
|
||||||
compiler.tree.def-use
|
compiler.tree.def-use
|
||||||
compiler.tree.recursive
|
compiler.tree.recursive
|
||||||
compiler.tree.combinators ;
|
compiler.tree.combinators ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.tree.checker
|
IN: compiler.tree.checker
|
||||||
|
|
||||||
! Check some invariants; this can help catch compiler bugs.
|
! Check some invariants; this can help catch compiler bugs.
|
||||||
|
|
|
@ -4,6 +4,7 @@ USING: sequences namespaces kernel accessors assocs sets fry
|
||||||
arrays combinators columns stack-checker.backend
|
arrays combinators columns stack-checker.backend
|
||||||
stack-checker.branches compiler.tree compiler.tree.combinators
|
stack-checker.branches compiler.tree compiler.tree.combinators
|
||||||
compiler.tree.dead-code.liveness compiler.tree.dead-code.simple ;
|
compiler.tree.dead-code.liveness compiler.tree.dead-code.simple ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.tree.dead-code.branches
|
IN: compiler.tree.dead-code.branches
|
||||||
|
|
||||||
M: #if mark-live-values* look-at-inputs ;
|
M: #if mark-live-values* look-at-inputs ;
|
||||||
|
|
|
@ -4,6 +4,7 @@ USING: fry accessors namespaces assocs deques search-deques
|
||||||
dlists kernel sequences compiler.utilities words sets
|
dlists kernel sequences compiler.utilities words sets
|
||||||
stack-checker.branches compiler.tree compiler.tree.def-use
|
stack-checker.branches compiler.tree compiler.tree.def-use
|
||||||
compiler.tree.combinators ;
|
compiler.tree.combinators ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.tree.dead-code.liveness
|
IN: compiler.tree.dead-code.liveness
|
||||||
|
|
||||||
SYMBOL: work-list
|
SYMBOL: work-list
|
||||||
|
|
|
@ -6,6 +6,7 @@ stack-checker.state
|
||||||
stack-checker.branches
|
stack-checker.branches
|
||||||
compiler.tree
|
compiler.tree
|
||||||
compiler.tree.combinators ;
|
compiler.tree.combinators ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.tree.def-use
|
IN: compiler.tree.def-use
|
||||||
|
|
||||||
SYMBOL: def-use
|
SYMBOL: def-use
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: sequences kernel fry vectors accessors namespaces assocs sets
|
USING: sequences kernel fry vectors accessors namespaces assocs sets
|
||||||
stack-checker.branches compiler.tree compiler.tree.def-use ;
|
stack-checker.branches compiler.tree compiler.tree.def-use ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.tree.def-use.simplified
|
IN: compiler.tree.def-use.simplified
|
||||||
|
|
||||||
! Simplified def-use follows chains of copies.
|
! Simplified def-use follows chains of copies.
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors assocs namespaces sequences kernel math
|
USING: accessors assocs namespaces sequences kernel math
|
||||||
combinators sets disjoint-sets fry stack-checker.values ;
|
combinators sets disjoint-sets fry stack-checker.values ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.tree.escape-analysis.allocations
|
IN: compiler.tree.escape-analysis.allocations
|
||||||
|
|
||||||
! A map from values to classes. Only for #introduce outputs
|
! A map from values to classes. Only for #introduce outputs
|
||||||
|
|
|
@ -9,6 +9,7 @@ compiler.tree.propagation.info
|
||||||
compiler.tree.def-use
|
compiler.tree.def-use
|
||||||
compiler.tree.def-use.simplified
|
compiler.tree.def-use.simplified
|
||||||
compiler.tree.late-optimizations ;
|
compiler.tree.late-optimizations ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.tree.modular-arithmetic
|
IN: compiler.tree.modular-arithmetic
|
||||||
|
|
||||||
! This is a late-stage optimization.
|
! This is a late-stage optimization.
|
||||||
|
|
|
@ -8,7 +8,7 @@ layouts compiler.tree.propagation.info compiler.tree.def-use
|
||||||
compiler.tree.debugger compiler.tree.checker slots.private words
|
compiler.tree.debugger compiler.tree.checker slots.private words
|
||||||
hashtables classes assocs locals specialized-arrays system
|
hashtables classes assocs locals specialized-arrays system
|
||||||
sorting math.libm math.floats.private math.integers.private
|
sorting math.libm math.floats.private math.integers.private
|
||||||
math.intervals quotations effects alien alien.data new-sets ;
|
math.intervals quotations effects alien alien.data sets ;
|
||||||
FROM: math => float ;
|
FROM: math => float ;
|
||||||
SPECIALIZED-ARRAY: double
|
SPECIALIZED-ARRAY: double
|
||||||
SPECIALIZED-ARRAY: void*
|
SPECIALIZED-ARRAY: void*
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
USING: alien.c-types kernel sequences words fry generic accessors
|
USING: alien.c-types kernel sequences words fry generic accessors
|
||||||
classes.tuple classes classes.algebra definitions
|
classes.tuple classes classes.algebra definitions
|
||||||
stack-checker.dependencies quotations classes.tuple.private math
|
stack-checker.dependencies quotations classes.tuple.private math
|
||||||
math.partial-dispatch math.private math.intervals new-sets.private
|
math.partial-dispatch math.private math.intervals sets.private
|
||||||
math.floats.private math.integers.private layouts math.order
|
math.floats.private math.integers.private layouts math.order
|
||||||
vectors hashtables combinators effects generalizations assocs
|
vectors hashtables combinators effects generalizations assocs
|
||||||
new-sets combinators.short-circuit sequences.private locals growable
|
sets combinators.short-circuit sequences.private locals growable
|
||||||
stack-checker namespaces compiler.tree.propagation.info ;
|
stack-checker namespaces compiler.tree.propagation.info ;
|
||||||
FROM: math => float ;
|
FROM: math => float ;
|
||||||
FROM: new-sets => set ;
|
FROM: sets => set ;
|
||||||
IN: compiler.tree.propagation.transforms
|
IN: compiler.tree.propagation.transforms
|
||||||
|
|
||||||
\ equal? [
|
\ equal? [
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel assocs arrays namespaces accessors sequences deques fry
|
USING: kernel assocs arrays namespaces accessors sequences deques fry
|
||||||
search-deques dlists combinators.short-circuit make sets compiler.tree ;
|
search-deques dlists combinators.short-circuit make sets compiler.tree ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.tree.recursive
|
IN: compiler.tree.recursive
|
||||||
|
|
||||||
TUPLE: call-site tail? node label ;
|
TUPLE: call-site tail? node label ;
|
||||||
|
|
|
@ -8,6 +8,7 @@ prettyprint.stylesheet quotations see sequences sets slots
|
||||||
sorting splitting strings vectors vocabs vocabs.loader words
|
sorting splitting strings vectors vocabs vocabs.loader words
|
||||||
words.symbol ;
|
words.symbol ;
|
||||||
FROM: prettyprint.sections => with-pprint ;
|
FROM: prettyprint.sections => with-pprint ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: help.markup
|
IN: help.markup
|
||||||
|
|
||||||
PREDICATE: simple-element < array
|
PREDICATE: simple-element < array
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespaces prettyprint prettyprint.custom prettyprint.sections
|
||||||
sequences strings io.styles vectors words quotations mirrors
|
sequences strings io.styles vectors words quotations mirrors
|
||||||
splitting math.parser classes vocabs sets sorting summary
|
splitting math.parser classes vocabs sets sorting summary
|
||||||
debugger continuations fry combinators ;
|
debugger continuations fry combinators ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: inspector
|
IN: inspector
|
||||||
|
|
||||||
SYMBOL: +number-rows+
|
SYMBOL: +number-rows+
|
||||||
|
|
|
@ -5,6 +5,7 @@ io vectors arrays math.parser math.order combinators classes
|
||||||
sets unicode.categories compiler.units parser effects.parser
|
sets unicode.categories compiler.units parser effects.parser
|
||||||
words quotations memoize accessors locals splitting
|
words quotations memoize accessors locals splitting
|
||||||
combinators.short-circuit generalizations ;
|
combinators.short-circuit generalizations ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: peg
|
IN: peg
|
||||||
|
|
||||||
TUPLE: parse-result remaining ast ;
|
TUPLE: parse-result remaining ast ;
|
||||||
|
|
|
@ -7,7 +7,7 @@ io.pathnames io.styles kernel make math math.order math.parser
|
||||||
namespaces prettyprint.config prettyprint.custom
|
namespaces prettyprint.config prettyprint.custom
|
||||||
prettyprint.sections prettyprint.stylesheet quotations sbufs
|
prettyprint.sections prettyprint.stylesheet quotations sbufs
|
||||||
sequences strings vectors words words.symbol hash-sets ;
|
sequences strings vectors words words.symbol hash-sets ;
|
||||||
FROM: new-sets => members ;
|
FROM: sets => members ;
|
||||||
IN: prettyprint.backend
|
IN: prettyprint.backend
|
||||||
|
|
||||||
M: effect pprint* effect>string "(" ")" surround text ;
|
M: effect pprint* effect>string "(" ")" surround text ;
|
||||||
|
|
|
@ -5,6 +5,7 @@ io.streams.string io.styles kernel make math math.parser namespaces
|
||||||
parser prettyprint.backend prettyprint.config prettyprint.custom
|
parser prettyprint.backend prettyprint.config prettyprint.custom
|
||||||
prettyprint.sections quotations sequences sorting strings vocabs
|
prettyprint.sections quotations sequences sorting strings vocabs
|
||||||
vocabs.prettyprint words sets generic ;
|
vocabs.prettyprint words sets generic ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: prettyprint
|
IN: prettyprint
|
||||||
|
|
||||||
: with-use ( obj quot -- )
|
: with-use ( obj quot -- )
|
||||||
|
|
|
@ -4,6 +4,7 @@ USING: arrays generic hashtables io kernel math assocs
|
||||||
namespaces make sequences strings io.styles vectors words
|
namespaces make sequences strings io.styles vectors words
|
||||||
prettyprint.config splitting classes continuations
|
prettyprint.config splitting classes continuations
|
||||||
accessors sets vocabs.parser combinators vocabs ;
|
accessors sets vocabs.parser combinators vocabs ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: prettyprint.sections
|
IN: prettyprint.sections
|
||||||
|
|
||||||
! State
|
! State
|
||||||
|
|
|
@ -5,6 +5,7 @@ sequences fry quotations math.order math.ranges vectors
|
||||||
unicode.categories regexp.transition-tables words sets hashtables
|
unicode.categories regexp.transition-tables words sets hashtables
|
||||||
combinators.short-circuit unicode.data regexp.ast
|
combinators.short-circuit unicode.data regexp.ast
|
||||||
regexp.classes memoize ;
|
regexp.classes memoize ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: regexp.nfa
|
IN: regexp.nfa
|
||||||
|
|
||||||
! This uses unicode.data for ch>upper and ch>lower
|
! This uses unicode.data for ch>upper and ch>lower
|
||||||
|
|
|
@ -8,6 +8,8 @@ io.streams.string io.styles kernel make namespaces prettyprint
|
||||||
prettyprint.backend prettyprint.config prettyprint.custom
|
prettyprint.backend prettyprint.config prettyprint.custom
|
||||||
prettyprint.sections sequences sets sorting strings summary words
|
prettyprint.sections sequences sets sorting strings summary words
|
||||||
words.symbol words.constant words.alias vocabs slots ;
|
words.symbol words.constant words.alias vocabs slots ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
|
FROM: classes => members ;
|
||||||
IN: see
|
IN: see
|
||||||
|
|
||||||
GENERIC: synopsis* ( defspec -- )
|
GENERIC: synopsis* ( defspec -- )
|
||||||
|
|
|
@ -6,6 +6,7 @@ continuations assocs combinators compiler.errors accessors math.order
|
||||||
definitions sets hints macros stack-checker.state
|
definitions sets hints macros stack-checker.state
|
||||||
stack-checker.visitor stack-checker.errors stack-checker.values
|
stack-checker.visitor stack-checker.errors stack-checker.values
|
||||||
stack-checker.recursive-state stack-checker.dependencies summary ;
|
stack-checker.recursive-state stack-checker.dependencies summary ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: stack-checker.backend
|
IN: stack-checker.backend
|
||||||
|
|
||||||
: push-d ( obj -- ) meta-d push ;
|
: push-d ( obj -- ) meta-d push ;
|
||||||
|
|
|
@ -5,6 +5,7 @@ generic kernel math namespaces sequences words sets
|
||||||
combinators.short-circuit classes.tuple alien.c-types ;
|
combinators.short-circuit classes.tuple alien.c-types ;
|
||||||
FROM: classes.tuple.private => tuple-layout ;
|
FROM: classes.tuple.private => tuple-layout ;
|
||||||
FROM: assocs => change-at ;
|
FROM: assocs => change-at ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: stack-checker.dependencies
|
IN: stack-checker.dependencies
|
||||||
|
|
||||||
! Words that the current quotation depends on
|
! Words that the current quotation depends on
|
||||||
|
|
|
@ -9,6 +9,7 @@ sequences.private generalizations stack-checker.backend
|
||||||
stack-checker.state stack-checker.visitor stack-checker.errors
|
stack-checker.state stack-checker.visitor stack-checker.errors
|
||||||
stack-checker.values stack-checker.recursive-state
|
stack-checker.values stack-checker.recursive-state
|
||||||
stack-checker.dependencies ;
|
stack-checker.dependencies ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: stack-checker.transforms
|
IN: stack-checker.transforms
|
||||||
|
|
||||||
: call-transformer ( stack quot -- newquot )
|
: call-transformer ( stack quot -- newquot )
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespaces make sequences words strings system hashtables math.parser
|
||||||
math.vectors classes.tuple classes boxes calendar alarms combinators
|
math.vectors classes.tuple classes boxes calendar alarms combinators
|
||||||
sets columns fry deques ui.gadgets ui.gadgets.private ascii
|
sets columns fry deques ui.gadgets ui.gadgets.private ascii
|
||||||
combinators.short-circuit ;
|
combinators.short-circuit ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: ui.gestures
|
IN: ui.gestures
|
||||||
|
|
||||||
: get-gesture-handler ( gesture gadget -- quot )
|
: get-gesture-handler ( gesture gadget -- quot )
|
||||||
|
|
|
@ -16,6 +16,7 @@ ui.tools.listener.completion ui.tools.listener.popups
|
||||||
ui.tools.listener.history ui.images ui.tools.error-list
|
ui.tools.listener.history ui.images ui.tools.error-list
|
||||||
tools.errors.model ;
|
tools.errors.model ;
|
||||||
FROM: source-files.errors => all-errors ;
|
FROM: source-files.errors => all-errors ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: ui.tools.listener
|
IN: ui.tools.listener
|
||||||
|
|
||||||
! If waiting is t, we're waiting for user input, and invoking
|
! If waiting is t, we're waiting for user input, and invoking
|
||||||
|
|
|
@ -6,6 +6,7 @@ math.parser hash2 math.order byte-arrays namespaces
|
||||||
compiler.units parser io.encodings.ascii values interval-maps
|
compiler.units parser io.encodings.ascii values interval-maps
|
||||||
ascii sets combinators locals math.ranges sorting make
|
ascii sets combinators locals math.ranges sorting make
|
||||||
strings.parser io.encodings.utf8 memoize simple-flat-file ;
|
strings.parser io.encodings.utf8 memoize simple-flat-file ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: unicode.data
|
IN: unicode.data
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
USING: accessors assocs checksums checksums.crc32
|
USING: accessors assocs checksums checksums.crc32
|
||||||
io.encodings.utf8 io.files kernel namespaces sequences sets
|
io.encodings.utf8 io.files kernel namespaces sequences sets
|
||||||
source-files vocabs vocabs.errors vocabs.loader ;
|
source-files vocabs vocabs.errors vocabs.loader ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: vocabs.refresh
|
IN: vocabs.refresh
|
||||||
|
|
||||||
: source-modified? ( path -- ? )
|
: source-modified? ( path -- ? )
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
USING: kernel classes classes.private combinators accessors
|
USING: kernel classes classes.private combinators accessors
|
||||||
sequences arrays vectors assocs namespaces words sorting layouts
|
sequences arrays vectors assocs namespaces words sorting layouts
|
||||||
math hashtables kernel.private sets math.order ;
|
math hashtables kernel.private sets math.order ;
|
||||||
|
FROM: classes => members ;
|
||||||
IN: classes.algebra
|
IN: classes.algebra
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
|
@ -4,6 +4,7 @@ USING: accessors arrays definitions assocs kernel kernel.private
|
||||||
slots.private namespaces make sequences strings words words.symbol
|
slots.private namespaces make sequences strings words words.symbol
|
||||||
vectors math quotations combinators sorting effects graphs
|
vectors math quotations combinators sorting effects graphs
|
||||||
vocabs sets ;
|
vocabs sets ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: classes
|
IN: classes
|
||||||
|
|
||||||
ERROR: bad-inheritance class superclass ;
|
ERROR: bad-inheritance class superclass ;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2008, 2010 Slava Pestov.
|
! Copyright (C) 2008, 2010 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors kernel new-sets namespaces make sequences parser
|
USING: accessors kernel sets namespaces make sequences parser
|
||||||
lexer combinators words classes.parser classes.tuple arrays
|
lexer combinators words classes.parser classes.tuple arrays
|
||||||
slots math assocs parser.notes classes classes.algebra ;
|
slots math assocs parser.notes classes classes.algebra ;
|
||||||
IN: classes.tuple.parser
|
IN: classes.tuple.parser
|
||||||
|
|
|
@ -147,7 +147,7 @@ ERROR: no-case object ;
|
||||||
: contiguous-range? ( keys -- ? )
|
: contiguous-range? ( keys -- ? )
|
||||||
dup [ fixnum? ] all? [
|
dup [ fixnum? ] all? [
|
||||||
dup all-unique? [
|
dup all-unique? [
|
||||||
[ prune length ]
|
[ length ]
|
||||||
[ [ supremum ] [ infimum ] bi - ]
|
[ [ supremum ] [ infimum ] bi - ]
|
||||||
bi - 1 =
|
bi - 1 =
|
||||||
] [ drop f ] if
|
] [ drop f ] if
|
||||||
|
|
|
@ -4,6 +4,7 @@ USING: accessors arrays kernel continuations assocs namespaces
|
||||||
sequences words vocabs definitions hashtables init sets math
|
sequences words vocabs definitions hashtables init sets math
|
||||||
math.order classes classes.private classes.algebra classes.tuple
|
math.order classes classes.private classes.algebra classes.tuple
|
||||||
classes.tuple.private generic source-files.errors kernel.private ;
|
classes.tuple.private generic source-files.errors kernel.private ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: compiler.units
|
IN: compiler.units
|
||||||
|
|
||||||
SYMBOL: old-definitions
|
SYMBOL: old-definitions
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors continuations kernel namespaces make
|
USING: accessors continuations kernel namespaces make
|
||||||
sequences vectors sets assocs init math ;
|
sequences vectors sets assocs init math ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: destructors
|
IN: destructors
|
||||||
|
|
||||||
SYMBOL: disposables
|
SYMBOL: disposables
|
||||||
|
|
|
@ -4,6 +4,7 @@ USING: accessors words kernel sequences namespaces make assocs
|
||||||
hashtables definitions kernel.private classes classes.private
|
hashtables definitions kernel.private classes classes.private
|
||||||
classes.algebra quotations arrays vocabs effects combinators
|
classes.algebra quotations arrays vocabs effects combinators
|
||||||
sets ;
|
sets ;
|
||||||
|
FROM: namespaces => set ;
|
||||||
IN: generic
|
IN: generic
|
||||||
|
|
||||||
! Method combination protocol
|
! Method combination protocol
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2010 Daniel Ehrenberg
|
! Copyright (C) 2010 Daniel Ehrenberg
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: new-sets tools.test kernel sorting prettyprint hash-sets ;
|
USING: sets tools.test kernel sorting prettyprint hash-sets ;
|
||||||
IN: hash-sets.tests
|
IN: hash-sets.tests
|
||||||
|
|
||||||
[ { 1 2 3 } ] [ HS{ 1 2 3 } members natural-sort ] unit-test
|
[ { 1 2 3 } ] [ HS{ 1 2 3 } members natural-sort ] unit-test
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2010 Daniel Ehrenberg
|
! Copyright (C) 2010 Daniel Ehrenberg
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors assocs hashtables kernel new-sets
|
USING: accessors assocs hashtables kernel sets
|
||||||
sequences parser ;
|
sequences parser ;
|
||||||
QUALIFIED: sets
|
QUALIFIED: sets
|
||||||
IN: hash-sets
|
IN: hash-sets
|
||||||
|
|
|
@ -1,26 +1,16 @@
|
||||||
USING: kernel sets tools.test ;
|
! Copyright (C) 2010 Daniel Ehrenberg
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: sets tools.test kernel prettyprint hash-sets sorting ;
|
||||||
IN: sets.tests
|
IN: sets.tests
|
||||||
|
|
||||||
[ f ] [ { 0 1 1 2 3 5 } all-unique? ] unit-test
|
|
||||||
[ t ] [ { 0 1 2 3 4 5 } all-unique? ] unit-test
|
|
||||||
|
|
||||||
[ V{ 1 2 3 } ] [ { 1 2 2 3 3 } prune ] unit-test
|
|
||||||
[ V{ 3 2 1 } ] [ { 3 3 2 2 1 } prune ] unit-test
|
|
||||||
|
|
||||||
[ { } ] [ { } { } intersect ] unit-test
|
[ { } ] [ { } { } intersect ] unit-test
|
||||||
[ { 2 3 } ] [ { 1 2 3 } { 2 3 4 } intersect ] unit-test
|
[ { 2 3 } ] [ { 1 2 3 } { 2 3 4 } intersect ] unit-test
|
||||||
|
|
||||||
[ { } ] [ { } { } diff ] unit-test
|
[ { } ] [ { } { } diff ] unit-test
|
||||||
[ { 1 } ] [ { 1 2 3 } { 2 3 4 } diff ] unit-test
|
[ { 1 } ] [ { 1 2 3 } { 2 3 4 } diff ] unit-test
|
||||||
|
|
||||||
[ V{ } ] [ { } { } union ] unit-test
|
[ { } ] [ { } { } union ] unit-test
|
||||||
[ V{ 1 2 3 4 } ] [ { 1 2 3 } { 2 3 4 } union ] unit-test
|
[ { 1 2 3 4 } ] [ { 1 2 3 } { 2 3 4 } union ] unit-test
|
||||||
|
|
||||||
[ V{ 1 2 3 } ]
|
|
||||||
[ 3 V{ 1 2 } clone [ adjoin ] keep ] unit-test
|
|
||||||
|
|
||||||
[ V{ 1 2 3 } ]
|
|
||||||
[ 3 V{ 1 3 2 } clone [ adjoin ] keep ] unit-test
|
|
||||||
|
|
||||||
[ t ] [ { 1 2 } { 1 3 } intersects? ] unit-test
|
[ t ] [ { 1 2 } { 1 3 } intersects? ] unit-test
|
||||||
|
|
||||||
|
@ -30,3 +20,34 @@ IN: sets.tests
|
||||||
|
|
||||||
[ 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,59 +1,112 @@
|
||||||
! Copyright (C) 2008, 2009 Slava Pestov, Doug Coleman.
|
! Copyright (C) 2010 Daniel Ehrenberg
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: assocs hashtables kernel sequences vectors ;
|
USING: accessors assocs hashtables kernel vectors
|
||||||
|
math sequences ;
|
||||||
IN: sets
|
IN: sets
|
||||||
|
|
||||||
: adjoin ( elt seq -- ) [ remove! drop ] [ push ] 2bi ;
|
! 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 -- ? )
|
||||||
|
|
||||||
: conjoin ( elt assoc -- ) dupd set-at ;
|
! Defaults for some methods.
|
||||||
|
! Override them for efficiency
|
||||||
|
|
||||||
: conjoin-at ( value key assoc -- )
|
M: set union
|
||||||
[ dupd ?set-at ] change-at ;
|
[ [ members ] bi@ append ] keep set-like ;
|
||||||
|
|
||||||
: (prune) ( elt hash vec -- )
|
|
||||||
3dup drop key? [ 3drop ] [
|
|
||||||
[ drop conjoin ] [ nip push ] 3bi
|
|
||||||
] if ; inline
|
|
||||||
|
|
||||||
: prune ( seq -- newseq )
|
|
||||||
[ ] [ length <hashtable> ] [ length <vector> ] tri
|
|
||||||
[ [ (prune) ] 2curry each ] keep ;
|
|
||||||
|
|
||||||
: duplicates ( seq -- newseq )
|
|
||||||
H{ } clone [ [ key? ] [ conjoin ] 2bi ] curry filter ;
|
|
||||||
|
|
||||||
: gather ( seq quot -- newseq )
|
|
||||||
map concat prune ; inline
|
|
||||||
|
|
||||||
: unique ( seq -- assoc )
|
|
||||||
[ dup ] H{ } map>assoc ;
|
|
||||||
|
|
||||||
: (all-unique?) ( elt hash -- ? )
|
|
||||||
2dup key? [ 2drop f ] [ conjoin t ] if ;
|
|
||||||
|
|
||||||
: all-unique? ( seq -- ? )
|
|
||||||
dup length <hashtable> [ (all-unique?) ] curry all? ;
|
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: tester ( seq -- quot ) unique [ key? ] curry ; inline
|
: tester ( set -- quot )
|
||||||
|
fast-set [ in? ] curry ; inline
|
||||||
|
|
||||||
|
: sequence/tester ( set1 set2 -- set1' quot )
|
||||||
|
[ members ] [ tester ] bi* ; inline
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: intersect ( seq1 seq2 -- newseq )
|
M: set intersect
|
||||||
tester filter ;
|
[ sequence/tester filter ] keep set-like ;
|
||||||
|
|
||||||
: intersects? ( seq1 seq2 -- ? )
|
M: set diff
|
||||||
tester any? ;
|
[ sequence/tester [ not ] compose filter ] keep set-like ;
|
||||||
|
|
||||||
: diff ( seq1 seq2 -- newseq )
|
M: set intersects?
|
||||||
tester [ not ] compose filter ;
|
sequence/tester any? ;
|
||||||
|
|
||||||
: union ( seq1 seq2 -- newseq )
|
M: set subset?
|
||||||
append prune ;
|
sequence/tester all? ;
|
||||||
|
|
||||||
: subset? ( seq1 seq2 -- ? )
|
M: set set=
|
||||||
tester all? ;
|
2dup subset? [ swap subset? ] [ 2drop f ] if ;
|
||||||
|
|
||||||
: set= ( seq1 seq2 -- ? )
|
M: set fast-set ;
|
||||||
[ unique ] bi@ = ;
|
|
||||||
|
M: set duplicates drop f ;
|
||||||
|
|
||||||
|
M: set all-unique? drop t ;
|
||||||
|
|
||||||
|
<PRIVATE
|
||||||
|
|
||||||
|
: (pruned) ( elt hash vec -- )
|
||||||
|
3dup drop in? [ 3drop ] [
|
||||||
|
[ drop adjoin ] [ nip push ] 3bi
|
||||||
|
] if ; inline
|
||||||
|
|
||||||
|
: pruned ( seq -- newseq )
|
||||||
|
[ f fast-set ] [ length <vector> ] bi
|
||||||
|
[ [ (pruned) ] 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
|
||||||
|
[ pruned ] keep like ;
|
||||||
|
|
||||||
|
M: sequence all-unique?
|
||||||
|
dup pruned sequence= ;
|
||||||
|
|
||||||
|
: 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 ;
|
||||||
|
|
||||||
|
! Temporarily for compatibility
|
||||||
|
|
||||||
|
ALIAS: prune members
|
||||||
|
: unique ( seq -- assoc )
|
||||||
|
[ dup ] H{ } map>assoc ;
|
||||||
|
: conjoin ( elt assoc -- )
|
||||||
|
dupd set-at ;
|
||||||
|
: conjoin-at ( value key assoc -- )
|
||||||
|
[ dupd ?set-at ] change-at ;
|
||||||
|
|
Loading…
Reference in New Issue