From 0fe701a837565aaf9c4e7f0bb36d2ad43464bb95 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 23 Apr 2010 08:19:21 -0600 Subject: [PATCH] add for/hasheqv for completeness --- collects/racket/private/for.rkt | 9 +++++++++ collects/scribblings/reference/for.scrbl | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/collects/racket/private/for.rkt b/collects/racket/private/for.rkt index 6a95bc7236..3a252a81dd 100644 --- a/collects/racket/private/for.rkt +++ b/collects/racket/private/for.rkt @@ -22,6 +22,7 @@ for/last for*/last for/hash for*/hash for/hasheq for*/hasheq + for/hasheqv for*/hasheqv for/fold/derived for*/fold/derived @@ -952,6 +953,14 @@ #`(let-values ([(key val) #,x]) (hash-set table key val)))) + (define-for-variants (for/hasheqv for*/hasheqv) + ([table #hasheqv()]) + (lambda (x) x) + (lambda (rhs) rhs) + (lambda (x) + #`(let-values ([(key val) #,x]) + (hash-set table key val)))) + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; specific sequences diff --git a/collects/scribblings/reference/for.scrbl b/collects/scribblings/reference/for.scrbl index 809f294f89..963d3dbb62 100644 --- a/collects/scribblings/reference/for.scrbl +++ b/collects/scribblings/reference/for.scrbl @@ -89,12 +89,14 @@ expression is a list of the results in order. @deftogether[( @defform[(for/hash (for-clause ...) body ...+)] @defform[(for/hasheq (for-clause ...) body ...+)] +@defform[(for/hasheqv (for-clause ...) body ...+)] )]{ Like @scheme[for/list], but the result is an immutable @tech{hash table}; @scheme[for/hash] creates a table using @scheme[equal?] to -distinguish keys, and @scheme[for/hasheq] produces a table using -@scheme[eq?]. The last expression in the @scheme[body]s must return +distinguish keys, @scheme[for/hasheq] produces a table using +@scheme[eq?], and @scheme[for/hasheqv] produces a table using +@scheme[eqv?]. The last expression in the @scheme[body]s must return two values: a key and a value to extend the hash table accumulated by the iteration. @@ -212,6 +214,7 @@ nested. @defform[(for*/lists (id ...) (for-clause ...) body ...+)] @defform[(for*/hash (for-clause ...) body ...+)] @defform[(for*/hasheq (for-clause ...) body ...+)] +@defform[(for*/hasheqv (for-clause ...) body ...+)] @defform[(for*/and (for-clause ...) body ...+)] @defform[(for*/or (for-clause ...) body ...+)] @defform[(for*/first (for-clause ...) body ...+)]