Skip to content

Instantly share code, notes, and snippets.

@tail-call
Created January 1, 2018 14:34
Show Gist options
  • Save tail-call/38f8cfd6a7664d3e0ef895968d8e6e40 to your computer and use it in GitHub Desktop.
Save tail-call/38f8cfd6a7664d3e0ef895968d8e6e40 to your computer and use it in GitHub Desktop.
#lang racket
(define (last items)
"Get the last element of ITEMS"
(foldl (lambda (x acc) x) (void) items))
@tail-call
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment