Created
November 25, 2013 18:32
-
-
Save ekajjake/7646216 to your computer and use it in GitHub Desktop.
Potential Final Problem
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
;;list number -> list | |
;;the function takes in a list and a number and returns a list of the first n elements. | |
(define (take a-list n) | |
(cond [(= 0 n) empty] | |
[else (cons (first a-list) (take (rest a-list)(- n 1))) ])) | |
(check-expect (take (list "a" "b" "c" "d" "e") 3)(list "a" "b" "c")) | |
(check-expect (take (list "a" "b" "c" "d" "e") 2)(list "a" "b")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment