Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #lang typed/racket
- ;; No `cast` or `inst` needed.
- (: functional (-> (U (-> Symbol Boolean)
- (-> Symbol Char))
- (-> Symbol String)))
- (define (functional prc)
- (lambda (smb)
- (let ((obj (prc smb)))
- (cond ((boolean? obj)
- (if obj "1" "0"))
- ((char? obj)
- (string obj))))))
- ;; Both `cast` and `inst` needed.
- (: hashish (-> (U (HashTable Symbol Boolean)
- (HashTable Symbol Char))
- (HashTable Symbol String)))
- (define (hashish hsh)
- ((inst hash-map/copy Symbol (U Boolean Char) Symbol String)
- (cast hsh (HashTable Symbol (U Boolean Char)))
- (lambda (smb obj)
- (cond ((boolean? obj)
- (values smb (if obj "1" "0")))
- ((char? obj)
- (values smb (string obj)))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement