From ec19948f35d876f5c64814a2905760b2f8763bb4 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 7 Apr 2012 09:25:07 -0700 Subject: Rounding out hash table functionality with lazy lists that can walk table content in different ways. * eval.c (op_dohash): Follow interface change of hash_next. (eval_init): hash-keys, hash-values, hash-pairs and hash-alist intrinsics introduced. * filter.c (trie_compress): Follow interface change of hash_next. * hash.c (hash_next): Silly interface which takes a pointer to the iterator has changed to just take the iterator. The function unambiguously returns nil when the iteration ends, so there is no need to set the iterator variable to nil. (maphash): Follows interface change of hash_next. (hash_keys_lazy, hash_values_lazy, hash_pairs_lazy, hash_alist_lazy): New static functions. (hash_keys, hash_values, hash_pairs, hash_alist): New functions. * hash.h (hash_next): Declaration updated. (hash_keys, hash_values, hash_pairs, hash_alist): Declared. * lib.c (make_half_lazy_cons): New way of constructing lazy cons, with the car field specified. It simplifies situations when the previous cons computes the car of the next one. Why hadn't I thought of this before? * lib.h (make_half_lazy_cons): Declared. * txr.1: Doc stubs for new hash functions. * txr.vim: Highlighting for new hash functions. --- lib.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib.h') diff --git a/lib.h b/lib.h index 1f8360c1..672f2fcf 100644 --- a/lib.h +++ b/lib.h @@ -397,6 +397,7 @@ int in_malloc_range(mem_t *); wchar_t *chk_strdup(const wchar_t *str); val cons(val car, val cdr); val make_lazy_cons(val func); +val make_half_lazy_cons(val func, val car); val lcons_fun(val lcons); val list(val first, ...); /* terminated by nao */ val consp(val obj); -- cgit v1.2.3