Skip to content

Instantly share code, notes, and snippets.

@christianromney
Created April 15, 2019 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianromney/ddf14a97db4f5886124780033aa80224 to your computer and use it in GitHub Desktop.
Save christianromney/ddf14a97db4f5886124780033aa80224 to your computer and use it in GitHub Desktop.
#lang racket
(define es (list 1 2 3))
(define base
(lambda (k)
(lambda (es)
'())))
(define step
(lambda (k)
(lambda (es)
(cons (first es)
(k (rest es))))))
(define butlast
(lambda (es)
((if (empty? (rest es))
(base identity)
(step butlast)) es)))
(butlast es) ;; => '(1 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment