#lang scheme (define (make-stack) (define stack '()) (lambda (arg) (if (eq? arg 'pop) (let ((popped (car stack))) (set! stack (cdr stack)) popped) (set! stack (cons arg stack)))))
Click here to download c17/stack.scm
.
#lang scheme (define (make-stack) (define stack '()) (lambda (arg) (if (eq? arg 'pop) (let ((popped (car stack))) (set! stack (cdr stack)) popped) (set! stack (cons arg stack)))))