Skip to content

Instantly share code, notes, and snippets.

@ruandao
Created November 16, 2016 03:20
Show Gist options
  • Save ruandao/b52df4104b338860fa5bee582dd08257 to your computer and use it in GitHub Desktop.
Save ruandao/b52df4104b338860fa5bee582dd08257 to your computer and use it in GitHub Desktop.
eopl 2.12
(define (empty-stack)
(lambda (action)
(cond ((eq? action 'top)
(repo-empty-stack-err))
((eq? action 'empty)
#t)
((eq? action 'pop)
(repo-empty-stack-err))
(else (repo-no-support-err)))))
(define (push stack var)
(lambda (action)
(cond ((eq? action 'top) var)
((eq? action 'empty) #f)
((eq? action 'pop) stack)
(else (repo-no-support-op)))))
(define (top stack)
(stack 'top))
(define (empty-stack? stack)
(stack 'empty?))
(define (pop stack)
(stack 'pop))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment