?value-at ( value assoc -- key/value ? )
Factor handbook » The language » Collections » Associative mapping operations » Lookup and querying of assocs

Prev:value-at ( value assoc -- key/f )
Next:assoc-empty? ( assoc -- ? )


Vocabulary
assocs

Inputs
valuean object
assocan assoc


Outputs
key/valuethe key associated to the value or the value if the value is not present in the assoc
?a boolean indicating if the value was present


Word description
Looks up the key associated with a value. If the value was not present, an error can be thrown without extra stack shuffling. This word handles assocs that store f.

Definition


: ?value-at ( value assoc -- key/value ? )
2dup value-at* [ 2nip t ] [ 2drop f ] if ; inline