Created
January 1, 2018 14:34
-
-
Save tail-call/38f8cfd6a7664d3e0ef895968d8e6e40 to your computer and use it in GitHub Desktop.
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
| #lang racket | |
| (define (last items) | |
| "Get the last element of ITEMS" | |
| (foldl (lambda (x acc) x) (void) items)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Basically, when you search for the last element of a single linked list, you bind a variable to the successive list parts until there are none.