Skip to content

Instantly share code, notes, and snippets.

@kmicinski
Created January 27, 2020 22:22
Show Gist options
  • Save kmicinski/257c8214f5a6e8ab9a5af76f968fb3d1 to your computer and use it in GitHub Desktop.
Save kmicinski/257c8214f5a6e8ab9a5af76f968fb3d1 to your computer and use it in GitHub Desktop.
#lang racket
;; Write a function that takes a list l, of numbers,
;; and returns a hash which maps each number to its
;; square
;;
;; hint: use a recursive (or tail-recursive) function
;; to loop over the elements of l and build up a hash
;; from each element, e, to (* e e). Finally, return
;; the hash.
(define (make-squares l)
;; correct type, but wrong result (no values)
(hash))
;; This should return #t if you're correct
(equal? (make-squares '(1 2 3)) (hash 1 1 2 4 3 9))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment