Hi all!

(I'm on 7.0)
Just to jump right to the point here are the hash example lines from the User 
Guide and a few added lines with comments that should make it clear what I am 
confused about:

(define ht (make-hash))
(hash-set! ht "apple" '(red round))
(hash-set! ht "banana" '(yellow long))
(writeln ht)
(writeln (list? (hash-ref ht "apple")))
;; This is how I assumed hash->list to behave:
(writeln (for/list ([key (hash-keys ht)])
           (list key (hash-ref ht key))))
;; This is how it behaves:
(writeln (hash->list ht))


This is the output I get:

#hash(("banana" . (yellow long)) ("apple" . (red round)))
#t
(("apple" (red round)) ("banana" (yellow long)))
(("banana" yellow long) ("apple" red round))

So I'm confused why the list is "flattened" by hash->list. I can manage the 
situation using for/list, I'm just wondering.

Thanks,
Jussi

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to