Last active
January 3, 2016 17:49
-
-
Save leontastic/8498250 to your computer and use it in GitHub Desktop.
Clone of Racket assoc built-in function, except uses equal? instead of is-equal?, and returns an error instead of #f if the element does not exist. See here: http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Flist..rkt%29._assoc%29%29
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
; find-assoc: Any AL -> (listof Any) | |
; (find-assoc id al) produces the first element of al whose *car* is equal to id. | |
(define (find-assoc id al) | |
(first (filter (lambda (x) (equal? (first x) id)) al))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment