Here is what I have so far, but I am unable to run it since there is an error so I don't know if it works, I am trying to create my own stack object using Object Oriented programming in DrRacket, I am using a dispatch method to call the different procedures I have if they are invoked properly. For example first I would create a stack and then I would push and pop to the stack and also be able to print it.
(define (make-stack)
(define my-stack '())
(define (pop)
(define (pop-helper my-stack)
(let ((result (car my-stack))))
(set! my-stack (cdr my-stack))
result)
(pop-helper my-stack))
(define (push)
(define (push-helper x my-stack)
(set! my-stack (cons x my-stack)))
(push-helper x my-stack))
(define (empty?)
(define (empty-helper my-stack)
(if (null? my-stack) #t
#f))
(empty-helper my-stack))
(define (print)
(define (print-helper my-stack)
(if (empty?) '()
(print (cdr my-stack))))
(print-helper my-stack))
(define (dispatch method)
(cond
((eq? method 'pop) pop)
((eq? method 'push) push)
((eq? method 'print) print)
(else (lambda() (display "Unknown Request: ")(display method)(newline)))))
dispatch)
thanks in advance!