Video time: 05m40s
Want this course?
length
Course: Recursion 101
In the first lesson in Recursion 101, we jump right into defining a function that we use all the time but might not think of as recursive: length, which calculates the length of a list. This lesson includes a video screencast and some code. The lesson is 6 minutes long.
In the first lesson in _Recursion 101, _we jump right into defining a function that we use all the time but might not think of as recursive: length
, which calculates the length of a list.
(defn length [ls]
(if (empty? ls)
0
(+ 1 (length (rest ls)))))