-
-
Save winny-/a5fa271a0e066165c73ed6673a96340b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define keys '(1 2 3)) | |
(define items '(4 5 6)) | |
(define expected (hash 1 4 | |
2 5 | |
3 6)) | |
(define (solution-1 x y) | |
(for/hash ([k x] | |
[v y]) | |
(values k v))) | |
(define (solution-2 x y) | |
(apply hash (foldr (λ (a b acc) | |
(cons a (cons b acc))) | |
'() keys items))) | |
(module+ test | |
(require rackunit) | |
(check-equal? (solution-1 keys items) expected) | |
(check-equal? (solution-2 keys items) expected)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment