Reputation: 24535
I tried to have user input function using code on this page: A simple Racket terminal interaction
(define entry_list (for/list ([line (in-lines)]
#:break (string=? line "done"))
(println line)))
(println entry_list)
Output is:
this
"this "
is
"is "
a
"a "
test
"test"
for testing only
"for testing only"
done
'(#<void> #<void> #<void> #<void> #<void>)
Why is the list consisting of only "void" items?
Upvotes: 2
Views: 93
Reputation: 69934
That is because the println
function returns #<void>
. If instead of println you put something that returned a different value for each line you would end up with a more interesting list.
For example, the following code should return a list with the lines that you typed in:
(define entry_list
(for/list ([line (in-lines)]
#:break (string=? line "done"))
line))
If you just want to print the lines then you could have used for
instead of for/list
, to avoid creating an useless list of voids at the end:
Upvotes: 5