blob: 2d46e0712026502a6f6403fbfefbd326a1ba3611 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
require "types"
def _pr_str(obj, print_readably=true)
_r = print_readably
return case obj
when List
"(" + obj.map{|x| _pr_str(x, _r)}.join(" ") + ")"
when Vector
"[" + obj.map{|x| _pr_str(x, _r)}.join(" ") + "]"
when String
if _r
"\"" + obj.gsub(/\\/, "\\\\") \
.gsub(/"/, "\\\\\"") \
.gsub(/\n/, "\\\\n") + "\""
else
obj
end
when nil
"nil"
else
obj.to_s
end
end
|