-
-
Save kosciCZ/856764125479e0afe43af3daebabe757 to your computer and use it in GitHub Desktop.
Recursively finding the length of a list in Lisp.
This file contains hidden or 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
(defun len (list) | |
(if list | |
(1+ (len (cdr list))) | |
0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This recurcsively counts list items. it cuts off first item, adds one to the count and then calls itself on the shortened list. When it hits zero items, it starts to return recursively.