You're introduced to:
- Defining functions
- Built in functions such as nth
- Naming things such as functions and values
- Lists
The exercises are to define a function that returns the second element in a list and at least a couple of implementations of a function that returns the third element in the list.
Here are my implementations of second:
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
(def second (fn [list] ( nth list 1 ) )) | |
(def secondMkTwo (fn [list] ( first (rest list) ) )) |
And here are my implementations of third:
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
(def third (fn [list] ( first ( rest (rest list) )))) | |
(def thirdMkTwo (fn [li] (second (rest list)))) |
No comments:
Post a Comment