New line in the scheme (Racket)

You can create a new line when you write using "display", for example

(display "exa \n mple")

But the problem is that there is no code to have a new line in the lines? How:

"exa \n mple" 

Expected →

exa
 mple

What I have:

exa \n mple

I could not find any information in the racket documentation or anywhere else.

+5
source share
2 answers

If you need a way to add a new line between lines, this will work:

(define s (string-append "exa " "\n" " mple"))
s
=> "exa \n mple"

(display s)
=> exa
    mple

In the above snippet, I use string-appendto combine two lines with a new line in the middle. As a result, the line swill have a new line between them when using it, for example, by displaying it.

, "exa \n mple", , , , , , ..

+6

- :

(display "line\nhola")

.

, , .

+4

All Articles