scheme
(define (create-stack) (let ((*s* '())) (lambda (op . args) (cond ((eq? op 'push) (set! *s* (cons (car args) *s*))) ((eq? op 'pop) (if (null? *s*) '() ((lambda (ret) (set! *s* (cdr *s*)) ret) (car *s*)))) (#t '()))))) 使い方は次のようにな…
(define (create-stack) (let ((*s* '())) (lambda (op . args) (cond ((eq? op 'push) (set! *s* (cons (car args) *s*))) ((eq? op 'pop) (if (null? *s*) '() ((lambda (ret) (set! *s* (cdr *s*)) ret) (car *s*)))) (#t '()))))) 使い方は次のようにな…