Factor: Rename <enum> to <enumerated> to not confuse with ENUM:s
parent
974f1aa505
commit
01aab7c884
|
@ -38,4 +38,4 @@ sequences splitting strings tools.test ;
|
|||
} [
|
||||
"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJKb2UifQ.ipevRNuRP6HflG8cFKnmUPtypruRC4fb1DWtoLL62SY"
|
||||
"." split [ base64> ] map
|
||||
] unit-test
|
||||
] unit-test
|
||||
|
|
|
@ -40,7 +40,7 @@ SYMBOLS: return-addresses gc-maps ;
|
|||
[ emit-gc-roots ] ?{ } make underlying>> % ;
|
||||
|
||||
: emit-base-table ( alist longest -- )
|
||||
-1 <array> <enum> swap assoc-union! seq>> emit-uints ;
|
||||
-1 <array> <enumerated> swap assoc-union! seq>> emit-uints ;
|
||||
|
||||
: derived-root-offsets ( gc-map -- offsets )
|
||||
derived-roots>> [ [ gc-root-offset ] bi@ ] assoc-map ;
|
||||
|
|
|
@ -43,7 +43,7 @@ TUPLE: huffman-code
|
|||
[ nip '[ _ swap _ set-at ] each ] 3bi ;
|
||||
|
||||
:: reverse-table ( tdesc n -- rtable )
|
||||
n f <array> <enum> :> table
|
||||
n f <array> <enumerated> :> table
|
||||
tdesc [ n table update-reverse-table ] huffman-each
|
||||
table seq>> ;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ ERROR: bad-zlib-header ;
|
|||
CONSTANT: clen-shuffle { 16 17 18 0 8 7 9 6 10 5 11 4 12 3 13 2 14 1 15 }
|
||||
|
||||
: get-table ( values size -- table )
|
||||
16 f <array> <enum>
|
||||
16 f <array> <enumerated>
|
||||
[ '[ _ push-at ] 2each ] keep
|
||||
seq>> rest-slice [ natural-sort ] map ; inline
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ SYMBOL: +number-rows+
|
|||
|
||||
GENERIC: add-numbers ( alist -- table' )
|
||||
|
||||
M: enum add-numbers ;
|
||||
M: enumerated add-numbers ;
|
||||
|
||||
M: assoc add-numbers
|
||||
+number-rows+ get [ [ prefix ] map-index ] when ;
|
||||
|
|
|
@ -129,7 +129,7 @@ PRIVATE>
|
|||
swapd each-permutation ; inline
|
||||
|
||||
: inverse-permutation ( seq -- permutation )
|
||||
<enum> sort-values keys ;
|
||||
<enumerated> sort-values keys ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
|
|
|
@ -59,5 +59,5 @@ GENERIC: make-mirror ( obj -- assoc )
|
|||
M: hashtable make-mirror ;
|
||||
M: hash-set make-mirror members make-mirror ;
|
||||
M: integer make-mirror drop f ;
|
||||
M: sequence make-mirror <enum> ;
|
||||
M: sequence make-mirror <enumerated> ;
|
||||
M: object make-mirror <mirror> ;
|
||||
|
|
|
@ -66,7 +66,7 @@ M: interpolated [undo-xml]
|
|||
|
||||
: >enum ( assoc -- enum )
|
||||
! Assumes keys are 0..n
|
||||
sort-keys values <enum> ;
|
||||
sort-keys values <enumerated> ;
|
||||
|
||||
: undo-xml ( xml -- quot )
|
||||
[undo-xml] '[ H{ } clone [ _ with-variables ] keep >enum ] ;
|
||||
|
|
|
@ -152,7 +152,7 @@ MACRO: interpolate-xml ( xml -- quot )
|
|||
[ [ var>> , ] each-interpolated ] { } make ;
|
||||
|
||||
: nenum ( ... n -- assoc )
|
||||
narray <enum> ; inline
|
||||
narray <enumerated> ; inline
|
||||
|
||||
: collect ( accum variables -- accum ? )
|
||||
{
|
||||
|
|
|
@ -19,19 +19,19 @@ $nl
|
|||
ARTICLE: "enums" "Enumerations"
|
||||
"An enumeration provides a view of a sequence as an assoc mapping integer indices to elements:"
|
||||
{ $subsections
|
||||
enum
|
||||
<enum>
|
||||
enumerated
|
||||
<enumerated>
|
||||
}
|
||||
"Inverting a permutation using enumerations:"
|
||||
{ $example "IN: scratchpad" ": invert ( perm -- perm' )" " <enum> sort-values keys ;" "{ 2 0 4 1 3 } invert ." "{ 1 3 0 4 2 }" } ;
|
||||
{ $example "IN: scratchpad" ": invert ( perm -- perm' )" " <enumerated> sort-values keys ;" "{ 2 0 4 1 3 } invert ." "{ 1 3 0 4 2 }" } ;
|
||||
|
||||
HELP: enum
|
||||
HELP: enumerated
|
||||
{ $class-description "An associative structure which wraps a sequence and maps integers to the corresponding elements of the sequence."
|
||||
$nl
|
||||
"Enumerations are mutable; note that deleting a key calls " { $link remove-nth! } ", which results in all subsequent elements being shifted down." } ;
|
||||
|
||||
HELP: <enum>
|
||||
{ $values { "seq" sequence } { "enum" enum } }
|
||||
HELP: <enumerated>
|
||||
{ $values { "seq" sequence } { "enumerated" enumerated } }
|
||||
{ $description "Creates a new enumeration." } ;
|
||||
|
||||
ARTICLE: "assocs-protocol" "Associative mapping protocol"
|
||||
|
|
|
@ -281,32 +281,32 @@ M: f assoc-like drop dup assoc-empty? [ drop f ] when ; inline
|
|||
|
||||
INSTANCE: sequence assoc
|
||||
|
||||
TUPLE: enum { seq read-only } ;
|
||||
TUPLE: enumerated { seq read-only } ;
|
||||
|
||||
C: <enum> enum
|
||||
C: <enumerated> enumerated
|
||||
|
||||
M: enum at*
|
||||
M: enumerated at*
|
||||
seq>> 2dup bounds-check?
|
||||
[ nth-unsafe t ] [ 2drop f f ] if ; inline
|
||||
|
||||
M: enum set-at seq>> set-nth ; inline
|
||||
M: enumerated set-at seq>> set-nth ; inline
|
||||
|
||||
M: enum delete-at seq>> remove-nth! drop ; inline
|
||||
M: enumerated delete-at seq>> remove-nth! drop ; inline
|
||||
|
||||
M: enum >alist ( enum -- alist ) ; inline
|
||||
M: enumerated >alist ( enumerated -- alist ) ; inline
|
||||
|
||||
M: enum keys seq>> length <iota> >array ; inline
|
||||
M: enumerated keys seq>> length <iota> >array ; inline
|
||||
|
||||
M: enum values seq>> >array ; inline
|
||||
M: enumerated values seq>> >array ; inline
|
||||
|
||||
M: enum assoc-size seq>> length ; inline
|
||||
M: enumerated assoc-size seq>> length ; inline
|
||||
|
||||
M: enum clear-assoc seq>> delete-all ; inline
|
||||
M: enumerated clear-assoc seq>> delete-all ; inline
|
||||
|
||||
INSTANCE: enum assoc
|
||||
INSTANCE: enumerated assoc
|
||||
|
||||
M: enum length seq>> length ; inline
|
||||
M: enumerated length seq>> length ; inline
|
||||
|
||||
M: enum nth-unsafe dupd seq>> nth-unsafe 2array ; inline
|
||||
M: enumerated nth-unsafe dupd seq>> nth-unsafe 2array ; inline
|
||||
|
||||
INSTANCE: enum immutable-sequence
|
||||
INSTANCE: enumerated immutable-sequence
|
||||
|
|
|
@ -103,7 +103,7 @@ M: tuple-class boa>object
|
|||
over [ slot-named* ] dip check-slot-exists drop ;
|
||||
|
||||
: assoc>object ( class slots values -- tuple )
|
||||
[ [ [ initial>> ] map <enum> ] keep ] dip
|
||||
[ [ [ initial>> ] map <enumerated> ] keep ] dip
|
||||
swap [ [ slot-named-checked ] curry dip ] curry assoc-map
|
||||
assoc-union! seq>> boa>object ;
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ GENERIC: compile-engine ( engine -- obj )
|
|||
[ over assumed [ compile-engine ] with-variable ] assoc-map ;
|
||||
|
||||
: direct-dispatch-table ( assoc n -- table )
|
||||
default get <array> <enum> swap assoc-union! seq>> ;
|
||||
default get <array> <enumerated> swap assoc-union! seq>> ;
|
||||
|
||||
: tag-number ( class -- n ) "type" word-prop ;
|
||||
|
||||
|
@ -184,7 +184,7 @@ M: tuple-dispatch-engine compile-engine
|
|||
tuple assumed [
|
||||
echelons>> compile-engines
|
||||
dup keys supremum 1 + f <array>
|
||||
<enum> swap assoc-union! seq>>
|
||||
<enumerated> swap assoc-union! seq>>
|
||||
] with-variable ;
|
||||
|
||||
PREDICATE: predicate-engine-word < word "owner-generic" word-prop ;
|
||||
|
|
|
@ -60,7 +60,7 @@ PRIVATE>
|
|||
[ fail f ] [ unsafe-amb ] if-empty ; inline
|
||||
|
||||
MACRO: amb-execute ( seq -- quot )
|
||||
[ length 1 - ] [ <enum> [ 1quotation ] assoc-map ] bi
|
||||
[ length 1 - ] [ <enumerated> [ 1quotation ] assoc-map ] bi
|
||||
'[ _ 0 unsafe-number-from-to nip _ case ] ;
|
||||
|
||||
: if-amb ( true false -- ? )
|
||||
|
|
|
@ -18,7 +18,7 @@ IN: html.parser.analyzer
|
|||
swap attributes>> key? ;
|
||||
|
||||
: find-all ( seq quot -- alist )
|
||||
[ <enum> >alist ] [ '[ second @ ] ] bi* filter ; inline
|
||||
[ <enumerated> >alist ] [ '[ second @ ] ] bi* filter ; inline
|
||||
|
||||
: loopn-index ( n quot -- )
|
||||
[ <iota> ] [ '[ @ not ] ] bi* find 2drop ; inline
|
||||
|
|
|
@ -13,5 +13,5 @@ IN: math.transforms.bwt
|
|||
|
||||
: ibwt ( i newseq -- seq )
|
||||
[ length ]
|
||||
[ <enum> sort-values '[ _ nth first2 ] ]
|
||||
[ <enumerated> sort-values '[ _ nth first2 ] ]
|
||||
[ replicate-as ] tri nip ;
|
||||
|
|
|
@ -184,10 +184,10 @@ PRIVATE>
|
|||
|
||||
: m/getseq ( keys -- vals )
|
||||
[ H{ } clone ] dip
|
||||
[ <enum> [ m/getq ] assoc-each ]
|
||||
[ <enumerated> [ m/getq ] assoc-each ]
|
||||
[ length 10 + NOOP <request> swap >>opaque send-request ]
|
||||
[
|
||||
<enum> [
|
||||
<enumerated> [
|
||||
assoc-size 10 + '[
|
||||
_ read-header [ check-opaque ] keep swap
|
||||
]
|
||||
|
|
|
@ -41,7 +41,7 @@ SYMBOL: total
|
|||
] assoc-map ;
|
||||
|
||||
: canonicalize-specializer-3 ( specializer -- specializer' )
|
||||
[ total get object <array> <enum> ] dip assoc-union! seq>> ;
|
||||
[ total get object <array> <enumerated> ] dip assoc-union! seq>> ;
|
||||
|
||||
: canonicalize-specializers ( methods -- methods' hooks )
|
||||
[
|
||||
|
|
|
@ -5,7 +5,7 @@ vectors ;
|
|||
IN: sequences.extras
|
||||
|
||||
: find-all ( ... seq quot: ( ... elt -- ... ? ) -- ... elts )
|
||||
[ <enum> ] dip '[ nip @ ] assoc-filter ; inline
|
||||
[ <enumerated> ] dip '[ nip @ ] assoc-filter ; inline
|
||||
|
||||
: reduce-from ( ... seq identity quot: ( ... prev elt -- ... next ) i -- ... result )
|
||||
[ swap ] 2dip each-from ; inline
|
||||
|
@ -403,10 +403,10 @@ INSTANCE: odds immutable-sequence
|
|||
[ dup empty? ] swap until drop ; inline
|
||||
|
||||
: arg-max ( seq -- n )
|
||||
<enum> [ second-unsafe ] supremum-by first ;
|
||||
<enumerated> [ second-unsafe ] supremum-by first ;
|
||||
|
||||
: arg-min ( seq -- n )
|
||||
<enum> [ second-unsafe ] infimum-by first ;
|
||||
<enumerated> [ second-unsafe ] infimum-by first ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ patterns: [
|
|||
name: "keyword.control.namespaces.factor"
|
||||
}
|
||||
{
|
||||
match: "(^|(?<=\\s))(>alist|<enum>|2cache|\\?at|\\?of|assoc|assoc>map|assoc-all\\?|assoc-any\\?|assoc-clone-like|assoc-combine|assoc-diff|assoc-diff!|assoc-differ|assoc-each|assoc-empty\\?|assoc-filter|assoc-filter!|assoc-filter-as|assoc-find|assoc-hashcode|assoc-intersect|assoc-like|assoc-map|assoc-map-as|assoc-partition|assoc-refine|assoc-size|assoc-stack|assoc-subset\\?|assoc-union|assoc-union!|assoc=|assoc\\?|at|at\\*|at\\+|cache|change-at|clear-assoc|delete-at|delete-at\\*|enum|enum\\?|extract-keys|inc-at|key\\?|keys|map>assoc|maybe-set-at|new-assoc|of|push-at|rename-at|set-at|sift-keys|sift-values|substitute|unzip|value-at|value-at\\*|value\\?|values|zip|zip-as|zip-index|zip-index-as)(\\s|$)"
|
||||
match: "(^|(?<=\\s))(>alist|<enumerated>|2cache|\\?at|\\?of|assoc|assoc>map|assoc-all\\?|assoc-any\\?|assoc-clone-like|assoc-combine|assoc-diff|assoc-diff!|assoc-differ|assoc-each|assoc-empty\\?|assoc-filter|assoc-filter!|assoc-filter-as|assoc-find|assoc-hashcode|assoc-intersect|assoc-like|assoc-map|assoc-map-as|assoc-partition|assoc-refine|assoc-size|assoc-stack|assoc-subset\\?|assoc-union|assoc-union!|assoc=|assoc\\?|at|at\\*|at\\+|cache|change-at|clear-assoc|delete-at|delete-at\\*|enum|enum\\?|extract-keys|inc-at|key\\?|keys|map>assoc|maybe-set-at|new-assoc|of|push-at|rename-at|set-at|sift-keys|sift-values|substitute|unzip|value-at|value-at\\*|value\\?|values|zip|zip-as|zip-index|zip-index-as)(\\s|$)"
|
||||
name: "keyword.control.assocs.factor"
|
||||
}
|
||||
{
|
||||
|
|
|
@ -54,7 +54,7 @@ syn match factorExecute /\<execute(\s\+\(\S*\s\+\)*--\(\s\+\S*\)*\s\+)\>/ contai
|
|||
syn keyword factorCallNextMethod call-next-method
|
||||
|
||||
syn keyword factorKeyword (clone) -rot 2bi 2bi* 2bi@ 2curry 2dip 2drop 2dup 2keep 2nip 2over 2tri 2tri* 2tri@ 2with 3bi 3curry 3dip 3drop 3dup 3keep 3tri 4dip 4drop 4dup 4keep <wrapper> = >boolean ? ?if and assert assert= assert? bi bi* bi-curry bi-curry* bi-curry@ bi@ boa boolean boolean? both? build call callstack callstack>array callstack? clear clone compose composed? curry curried? die dip do drop dup dupd either? eq? equal? execute get-callstack get-datastack get-retainstack hashcode hashcode* identity-hashcode identity-tuple identity-tuple? if if* keep loop most new nip not null object or over pick prepose rot same? swap swapd throw tri tri* tri-curry tri-curry* tri-curry@ tri@ tuple tuple? unless unless* until when when* while with wrapper wrapper? xor
|
||||
syn keyword factorKeyword 2cache <enum> >alist ?at ?of assoc assoc-all? assoc-any? assoc-clone-like assoc-combine assoc-diff assoc-diff! assoc-differ assoc-each assoc-empty? assoc-filter assoc-filter! assoc-filter-as assoc-find assoc-hashcode assoc-intersect assoc-like assoc-map assoc-map-as assoc-partition assoc-refine assoc-reject assoc-reject! assoc-reject-as assoc-size assoc-stack assoc-subset? assoc-union assoc-union! assoc= assoc>map assoc? at at* at+ cache change-at clear-assoc delete-at delete-at* enum enum? extract-keys harvest-keys harvest-values inc-at key? keys map>alist map>assoc maybe-set-at new-assoc of push-at rename-at set-at sift-keys sift-values substitute unzip value-at value-at* value? values zip zip-as zip-index zip-index-as
|
||||
syn keyword factorKeyword 2cache <enumerated> >alist ?at ?of assoc assoc-all? assoc-any? assoc-clone-like assoc-combine assoc-diff assoc-diff! assoc-differ assoc-each assoc-empty? assoc-filter assoc-filter! assoc-filter-as assoc-find assoc-hashcode assoc-intersect assoc-like assoc-map assoc-map-as assoc-partition assoc-refine assoc-reject assoc-reject! assoc-reject-as assoc-size assoc-stack assoc-subset? assoc-union assoc-union! assoc= assoc>map assoc? at at* at+ cache change-at clear-assoc delete-at delete-at* enum enum? extract-keys harvest-keys harvest-values inc-at key? keys map>alist map>assoc maybe-set-at new-assoc of push-at rename-at set-at sift-keys sift-values substitute unzip value-at value-at* value? values zip zip-as zip-index zip-index-as
|
||||
syn keyword factorKeyword 2cleave 2cleave>quot 3cleave 3cleave>quot 4cleave 4cleave>quot alist>quot call-effect case case-find case>quot cleave cleave>quot cond cond>quot deep-spread>quot execute-effect linear-case-quot no-case no-case? no-cond no-cond? recursive-hashcode shallow-spread>quot spread to-fixed-point wrong-values wrong-values?
|
||||
syn keyword factorKeyword (all-integers?) (each-integer) (find-integer) * + - / /f /i /mod 2/ 2^ < <= <fp-nan> > >= >bignum >fixnum >float >fraction >integer >rect ?1+ abs align all-integers? bignum bignum? bit? bitand bitnot bitor bits>double bits>float bitxor complex complex? denominator double>bits each-integer even? fast-gcd find-integer find-last-integer fixnum fixnum? float float>bits float? fp-bitwise= fp-infinity? fp-nan-payload fp-nan? fp-qnan? fp-sign fp-snan? fp-special? gcd if-zero imaginary-part integer integer>fixnum integer>fixnum-strict integer? log2 log2-expects-positive log2-expects-positive? mod neg neg? next-float next-power-of-2 number number= number? numerator odd? power-of-2? prev-float ratio ratio? rational rational? real real-part real? recip rect> rem sgn shift sq times u< u<= u> u>= unless-zero unordered? when-zero zero?
|
||||
syn keyword factorKeyword 1sequence 2all? 2each 2each-from 2map 2map-as 2map-reduce 2reduce 2selector 2sequence 3append 3append-as 3each 3map 3map-as 3sequence 4sequence <repetition> <reversed> <slice> ?first ?last ?nth ?second ?set-nth accumulate accumulate! accumulate-as all? any? append append! append-as assert-sequence assert-sequence= assert-sequence? binary-reduce bounds-check bounds-check? bounds-error bounds-error? but-last but-last-slice cartesian-each cartesian-map cartesian-product change-nth check-slice clone-like collapse-slice collector collector-for concat concat-as copy count cut cut* cut-slice delete-all delete-slice drop-prefix each each-from each-index empty? exchange filter filter! filter-as find find-from find-index find-index-from find-last find-last-from first first2 first3 first4 flip follow fourth glue halves harvest head head* head-slice head-slice* head? if-empty immutable immutable-sequence immutable-sequence? immutable? index index-from indices infimum infimum-by insert-nth interleave iota iota-tuple iota-tuple? join join-as last last-index last-index-from length lengthen like longer longer? longest map map! map-as map-find map-find-last map-index map-index-as map-integers map-reduce map-sum max-length member-eq? member? midpoint@ min-length mismatch move new-like new-resizable new-sequence non-negative-integer-expected non-negative-integer-expected? nth nths pad-head pad-tail padding partition pop pop* prefix prepend prepend-as produce produce-as product push push-all push-either push-if reduce reduce-index reject reject! reject-as remove remove! remove-eq remove-eq! remove-nth remove-nth! repetition repetition? replace-slice replicate replicate-as rest rest-slice reverse reverse! reversed reversed? second selector selector-for sequence sequence-hashcode sequence= sequence? set-first set-fourth set-last set-length set-nth set-second set-third short shorten shorter shorter? shortest sift slice slice-error slice-error? slice? snip snip-slice subseq-start subseq-start-from subseq subseq? suffix suffix! sum sum-lengths supremum supremum-by surround tail tail* tail-slice tail-slice* tail? third trim trim-head trim-head-slice trim-slice trim-tail trim-tail-slice unclip unclip-last unclip-last-slice unclip-slice unless-empty virtual-exemplar virtual-sequence virtual-sequence? virtual@ when-empty
|
||||
|
|
Loading…
Reference in New Issue