File: write-to-string

package info (click to toggle)
scheme9 2025.08.12-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,080 kB
  • sloc: lisp: 16,752; ansic: 11,869; sh: 806; makefile: 237; sed: 6
file content (15 lines) | stat: -rw-r--r-- 604 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
S9 LIB  (write-to-string object)    ==>  string
        (display-to-string object)  ==>  string

        (load-from-library "write-to-string.scm")

Write the external representation of the given OBJECT to a fresh
string. WRITE-TO-STRING is like WRITE but writes its output to a
string instead of an output port. DISPLAY-TO-STRING is like
DISPLAY but writes its output to a string.

(write-to-string '(a 1 #\c #(v) #t "str" "\"s\"" (a . d)))
  ==>  "(a 1 #\\c #(v) #t \"str\" \"\\\"s\\\"\" (a . d))"

(display-to-string '(a 1 #\c #(v) #t "str" "\"s\"" (a . d)))
  ==>  "(a 1 c #(v) #t str \"s\" (a . d))"