Define a portable eval variation which assumes the current environment. In Kawa, this is is equivalent to the standard eval.
(define sol-eval eval)
Since the current version of Kawa lacks cons*, I'm implementing it here for convenience.
(defmacro cons* args
(letrec
((recursive-cons
(lambda (list)
(if (and (list? list) (null? (cdr list)))
(car list)
`(cons ,(car list) ,(recursive-cons (cdr list)))))))
`(cons ,(car args) ,(recursive-cons (cdr args)))))
Prompt for interactive sessions - hacked from kawa source tree.
(define (sol-prompter port)
(let ((state (input-port-read-state port)))
(if (char=? state #\Newline)
""
(string-append (if (char=? state #\Space)
"#
|
Sol:"
(string-append "#
|
" (make-string 1 state) "---:"))
(number->string (input-port-line-number port))
"
|
# "))))
Make it the default prompter.
(set-input-port-prompter! (current-input-port) sol-prompter)