Created
August 9, 2013 22:12
-
-
Save banderson623/6197738 to your computer and use it in GitHub Desktop.
stupid scheme...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define empty-stack-v (lambda () (vector) )) | |
(define empty-stack-v? (lambda(stack) (equal? stack (empty-stack-v)))) | |
(define push-v (lambda (stack item) | |
(if (eqv? stack (empty-stack-v)) (vector item) | |
(vector-append (vector item) stack)) | |
)) | |
(define pop-v (lambda (stack) | |
(if (equal? stack (empty-stack-v)) | |
#f ; stack is empty | |
(vector-take-right stack (- (vector-length stack) 1)) | |
))) | |
(define top-v (lambda (stack) | |
(if (equal? stack (empty-stack-v)) | |
#f ; This is what happens when the stack is empty | |
(vector-ref stack (- (vector-length stack) 1)) | |
))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment