Reputation: 285
I have a list of strings in kumo
. I am printing three strings. I am getting them on 3 lines. I want them on one line separated by spaces. I am using the following code:
(display (first kumo))
(display (fourth kumo))
(display (second kumo))
or
(printf "~a~a~a" (first kumo)(fourth kumo)(second kumo))
Upvotes: 0
Views: 3684
Reputation: 17203
Hmm... unless I'm misunderstanding you, Racket already does that. Here's a small (complete) program illustrating this:
#lang racket
(define kumo (list "the" "very" "big" "dog"))
(printf "~a~a~a" (first kumo)(fourth kumo)(second kumo))
... which produces
thedogvery
If you want spaces between the words, put them in the format string:
#lang racket
(define kumo (list "the" "very" "big" "dog"))
(printf "~a ~a ~a" (first kumo)(fourth kumo)(second kumo))
... which produces
the dog very
You can do the same thing with display
, by displaying a string containing a single space in between the calls that display the words.
If I had to guess at your problem, I'd say that the strings you're displaying have newlines embedded in them.
Upvotes: 8