version of racket/drSCHEME i use does not allow me to use internal definitions using (R5RS) language
like these two for examples below give me error messages
define: not allowed in an expression context in: (define inp (read-command))
(define repl
(lambda()
(display "\nUofL>")
(define inp (read-command))
(define lengtha (length com))
(cond
((equal? inp "CLEAR")(set! lista '())(repl))
((equal? inp "REV")(set! lista (cdr lista))(set! lista (rev lista))(repl))
((equal? inp "STACK")(set! lista (cdr lista))(display lista)(repl))
((equal? inp "SWAP")(set! lista (cdr lista))(set! lista (append (list (cadr lista)) (list (car lista)) (cddr lista)))(repl))
((equal? (car lista) "EXIT") (display "Bye.")(set! lista (cdr lista)))
((equal? inp "DROP")(set! lista (cddr lista))(repl))
((equal? (car lista) "POP")
(set! lista (cdr lista))
(cond
((null? lista)(display "Empty Stack")(repl))
((string->number (car lista))(set! pop (car lista))(set! lista (cdr lista))(repl) )
((search (car lista) sym symval)
(cond
((null? (cdr lista)) (set! lista (cdr lista))
(display "Empty Stack") (repl))
(else
(addsym (car lista) (cadr lista))
(set! pop (cadr lista))
(set! lista (cddr lista))
(repl))))
(else
(set! lista (cdr lista))
(display "Var not declared")(repl))))
((equal? inp "SAVE")
(set! lista (cdr lista))
(cond
((equal? pop "")(display "Can't SAVE null"))
(else (set! lista (append (list pop) lista))(set! pop "")))
(repl))
((equal? inp "DUP")(set! lista (cdr lista))(set! lista (append (list (car lista)) lista))(repl))
((equal? (op? (car lista)) ".")(set! lista (cdr lista))
(cond
((equal? lengtha 1)(if (null? lista) (display "Empty Stack") (display (car lista)))(repl))
(else (displayn (- lengtha 1))(repl))))
((string->number (car lista))
(cond
((null? (cdr lista))(repl))
((op? (cadr lista))(repl))
(else (set! lista (cleanup-eval lista))(repl))))
((equal? (car lista) "define")
(set! lista (cdr lista))
(set! sym (append (list (car lista)) sym))
(set! lista (cdr lista))
(cond
((string->number (car lista))
(set! symval (append (list (string->number (car lista))) symval)))
(else
(set! symval (append (list (car lista)) symval))))
(set! lista (cdr lista))
(repl) )
(else
(cond
((search (car lista) sym symval)(set! lista (append (list (cadr res)) (cdr lista)))
(if (number? (car lista)) (set! lista (append (list(number->string (car lista)))))))
(else
(display (car lista))(set! lista (cdr lista))))))
(repl))))
edit: for the above definition, i tried doing this as an alternative, but it just results in my stack,rev and the other command just printing out their own names...
(define repl
(lambda()
(display "\nUofL>")
(let ((inp (read-command))
(lengtha (length com))