From 4ecca7c0b2ac3d61658d749f51dc1e7fbc408ed8 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 4 Aug 2015 08:37:51 -0700 Subject: * hash.c (hash_revget): New function. * hash.h (hash_revget): Declared. * eval.c (eval_init): Registered hash-revget intrinsic. * txr.1: Documented hash-revget. --- txr.1 | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index a1ff068b..19984c25 100644 --- a/txr.1 +++ b/txr.1 @@ -25301,6 +25301,50 @@ to The function returns .codn nil . +.coNP Function @ hash-revget +.synb +.mets (hash-revget < hash < value >> [ testfun <> [ keyfun ]]) +.syne +.desc +The +.code hash-revget +function performs a reverse lookup on +.metn hash . + +It searches through the entries stored in +.meta hash +for an entry whose value matches +.metn value . + +If such an entry is found, that entry's key is returned. +Otherwise +.code nil +is returned. + +If multiple matching entries exist, it is not specified which entry's +key is returned. + +The +.meta keyfun +function is applied to each value in +.meta hash +and the resulting value is compared with +.metn value . +The default +.meta keyfun +is the +.code identity +function. + +The comparison is performed using +.metn testfun . + +The default +.meta testfun +is the +.code eql +function. + .coNP Functions @ hash-eql and @ hash-equal .synb .mets (hash-eql << object ) -- cgit v1.2.3