
The old 'HashTable' type is now the union of the other 3 hash types. - all operations that used to work on 'HashTable's still work, but some now have more specific outputs - `#hash` literals have type `ImmutableHash` - `immutable?` and `hash-weak?` are filters - `Mutable-` and `Weak-` hashes have corresponding `Top` types, `HashTableTop` is now a union - the contact for `(U (Immutable-Hash K1 V1) (Mutable-Hash K2 V2))` is ONE `hash/c` Minor notes: - renamed internal identifiers containing 'Hashtable' to all use 'HashTable' - add Racket guide/reference 'secref' functions
19 lines
752 B
Racket
19 lines
752 B
Racket
#lang typed/racket
|
|
|
|
(define: memo : (HashTable Natural String) (make-immutable-hash empty))
|
|
(define strs '("Hello" "Goodbye"))
|
|
|
|
(for/fold: : (HashTable Natural String)
|
|
([memo : (HashTable Natural String) (make-immutable-hash empty)])
|
|
([i : Natural (in-naturals)] [str : String (in-list strs)])
|
|
(hash-set memo i str))
|
|
|
|
(let () ;;bg: same code should work with Immutable-Hash type
|
|
(define: memo2 : (Immutable-HashTable Natural String) (make-immutable-hash empty))
|
|
(define strs2 '("Hello" "Goodbye"))
|
|
|
|
(for/fold: : (Immutable-HashTable Natural String)
|
|
([memo2 : (Immutable-HashTable Natural String) (make-immutable-hash empty)])
|
|
([i : Natural (in-naturals)] [str : String (in-list strs2)])
|
|
(hash-set memo2 i str)))
|