add for/hasheqv for completeness

This commit is contained in:
Matthew Flatt 2010-04-23 08:19:21 -06:00
parent 12b95ece4c
commit 0fe701a837
2 changed files with 14 additions and 2 deletions

View File

@ -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

View File

@ -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 ...+)]