Handbook
Glossary
assoc-like ( assoc exemplar -- newassoc )
Factor handbook
»
The language
»
Collections
»
Associative mapping operations
»
Associative mapping protocol
Prev:
new-assoc ( capacity exemplar -- newassoc )
Next:
assoc= ( assoc1 assoc2 -- ? )
Vocabulary
assocs
Inputs
assoc
an
assoc
exemplar
an
assoc
Outputs
newassoc
a new assoc
Generic word contract
Creates a new assoc having the same entries as
assoc
and the same type as
exemplar
.
Definition
IN:
assocs
GENERIC:
assoc-like
( assoc exemplar -- newassoc )
Methods
USING:
assocs
kernel
;
M:
assoc
assoc-like
drop
;
inline
USING:
assocs
kernel
xml.data
;
M:
attrs
assoc-like
drop
dup
attrs?
[
>attrs
]
unless
;
USING:
assocs
kernel
trees.avl
;
M:
avl
assoc-like
drop
dup
avl?
[
>avl
]
unless
;
USING:
assocs
kernel
;
M:
f
assoc-like
drop
dup
assoc-empty?
[
drop
f
]
when
;
inline
USING:
assocs
hashtables
kernel
;
M:
hashtable
assoc-like
drop
dup
hashtable?
[
>hashtable
]
unless
;
inline
USING:
assocs
hashtables.identity
kernel
;
M:
identity-hashtable
assoc-like
drop
dup
identity-hashtable?
[
>identity-hashtable
]
unless
;
inline
USING:
accessors
assocs
classes
kernel
linked-assocs
;
M:
linked-assoc
assoc-like
over
linked-assoc?
[
2dup
[
assoc>>
]
bi@
class-of
instance?
]
[
f
]
if
[
drop
]
[
assoc>>
<linked-assoc>
swap
assoc-union!
]
if
;
USING:
assocs
kernel
sequences
;
M:
sequence
assoc-like
[
>alist
]
dip
like
;
inline
USING:
assocs
kernel
trees.splay
;
M:
splay
assoc-like
drop
dup
splay?
[
>splay
]
unless
;
USING:
accessors
assocs
kernel
xml.data
;
M:
tag
assoc-like
[
attrs>>
]
call
\
assoc-like
execute
;
USING:
assocs
kernel
trees
;
M:
tree
assoc-like
drop
dup
tree?
[
>tree
]
unless
;
USING:
assocs
kernel
vlists
;
M:
valist
assoc-like
drop
dup
valist?
[
>valist
]
unless
;