From 1c11fe21f49559fbb0f2ee8fa9b702338207e7a0 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 12 Oct 2016 21:10:40 -0700 Subject: find-max and find-min support hashes. * lib.c (find_max): Restructured to implement separately for vectors and lists. Support hash tables. * txr.1: Document find-min and find-max for hashes. --- txr.1 | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index f19603cc..8569f797 100644 --- a/txr.1 +++ b/txr.1 @@ -23877,8 +23877,8 @@ the leftmost. .coNP Functions @ find-max and @ find-min .synb -.mets (find-max < sequence >> [ testfun <> [ keyfun ]]) -.mets (find-min < sequence >> [ testfun <> [ keyfun ]]) +.mets (find-max >> { sequence | << hash } >> [ testfun <> [ keyfun ]]) +.mets (find-min >> { sequence | << hash } >> [ testfun <> [ keyfun ]]) .syne .desc The @@ -23940,6 +23940,25 @@ is passed through this one-argument function, and the resulting value is used in its place for the purposes of the comparison. However, the original element is returned. +A hash table may be specified instead of a sequence. +The +.meta hash +is treated as if it were a sequence of hash key and hash +value pairs represented as cons cells, the +.code car +slots of which are the hash keys, and the +.code cdr +of which are the hash values. If the caller doesn't specify a +.meta keyfun +then these cells are taken as their keys. To find the hash +table's key-value cell with the maximum key, the +.code car +function can be specified as +.metn keyfun . +To find the entry holding the maximum value, the +.code cdr +function can be specified. + .coNP Function @ set-diff .synb .mets (set-diff < seq1 < seq2 >> [ testfun <> [ keyfun ]]) -- cgit v1.2.3