Permalink
Browse files

added hash-find function

  • Loading branch information...
1 parent 177ca2c commit c569e588b391226575834e19864835ca5bf8e3d1 @vegashacker committed Oct 14, 2008
Showing with 5 additions and 0 deletions.
  1. +5 −0 util.scm
View
5 util.scm
@@ -75,6 +75,7 @@
hash-singleton-value
hash-filter-map
hash-hash-map
+ hash-find
bucketed-hash-add!
fold ;(iterative-style)
fold-right ;(recursive-style)
@@ -319,6 +320,10 @@
(hash-for-each ht (lambda (k v) (hash-set! fresh-ht k (fn k v))))
fresh-ht))
+;; fn : key X val -> #f | alpha
+(define (hash-find ht fn)
+ (find (lambda (k) (fn k (hash-ref ht k))) (hash-keys ht)))
+
(define (bucketed-hash-add! bht key val)
(hash-set! bht key (cons val (hash-ref bht key '()))))

0 comments on commit c569e58

Please sign in to comment.