From 8230a637a32ce0c88ba1c51aeb6c2d5edcece109 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 15 Nov 2017 06:19:49 -0800 Subject: find-if: optimized rewrite and hash support. * lib.c (find_if): Function rewritten to use the seq_info sequence classification mechanism, for much better performance on vector-like objects. Also, supports hash tables just like find_max. * txr.1: Documentation updated regarding hash support of find-if. --- txr.1 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index ab75e874..d7f3ad91 100644 --- a/txr.1 +++ b/txr.1 @@ -27419,7 +27419,7 @@ is returned. .coNP Functions @ find and @ find-if .synb .mets (find < key < sequence >> [ testfun <> [ keyfun ]]) -.mets (find-if < predfun < sequence <> [ keyfun ]) +.mets (find-if < predfun >> { sequence | << hash } <> [ keyfun ]) .syne .desc The @@ -27474,6 +27474,20 @@ element is found, .code nil is returned. +In the case of +.codn find-if , +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. + .coNP Functions @ rfind and @ rfind-if .synb .mets (rfind < key < sequence >> [ testfun <> [ keyfun ]]) -- cgit v1.2.3