I know you can use (read) to get a user-inputted expression, but (read) will only get the first expression, evaluating anything afterwards. I was wondering if there was any way I could read an entire line of user input, perhaps turning said line into a list?
(let ((input (read-user-line)))
;; user could type "cons 2 3" without quotes
;; input could contain '(cons 2 3)
(apply (car input) (cdr input)))
Thanks!
If your Scheme is an R6RS implementation, you can use GET-LINE. If that same Scheme implements SRFI-13 as well, you can use STRING-TOKENIZE to turn it into a list.
One Scheme that qualifies is Ypsilon:
(import (srfi srfi-13)) (let ((input (get-line (current-input-port)))) (for-each (lambda (x) (display x) (newline)) (string-tokenize input)))Otherwise you are on your own with whatever non-standard extensions your implementation provides.