?at
of
?of
+ value-at
+ ?value-at
assoc-empty?
keys
values
{ $values { "value" object } { "assoc" assoc } { "key/f" { $maybe "the key associated to the value" } } }
{ $description "Looks up the key associated with a value. No distinction is made between a missing key and a key set to " { $link f } "." } ;
+HELP: ?value-at
+{ $values { "value" object } { "assoc" assoc } { "key/value" "the key associated to the value or the value if the value is not present in the assoc" } { "?" "a " { $link boolean } " indicating if the value was present" } }
+{ $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 " { $link f } "." } ;
+
HELP: value?
{ $values { "value" object } { "assoc" assoc } { "?" boolean } }
{ $description "Tests if an assoc contains at least one key with the given value." } ;
: value-at ( value assoc -- key/f ) value-at* drop ;
+: ?value-at ( value assoc -- key/value ? )
+ 2dup value-at* [ 2nip t ] [ 2drop f ] if ; inline
+
: value? ( value assoc -- ? ) value-at* nip ;
: push-at ( value key assoc -- )