1 import types
.{MalList
, MalVector
, MalHashMap
, MalFunction
}
5 def _pr_str(obj
: Any
, print_readably
: Boolean
= true): String
= {
6 val _r
= print_readably
8 case v
: MalVector
=> v
.toString(_r
)
9 case l
: MalList
=> l
.toString(_r
)
10 case hm
: MalHashMap
=> hm
.toString(_r
)
12 if (s
.length
> 0 && s(0) == '\u029e') {
13 ":" + s
.substring(1,s
.length
)
15 //println("here1: " + s)
16 "\"" + s
.replace("\\", "\\\\")
17 .replace("\"", "\\\"")
18 .replace("\n", "\\n") + "\""
24 case a
: types
.Atom
=> "(atom " + a
.value
+ ")"
27 if (obj
.isInstanceOf
[MalFunction
]) {
28 val f
= obj
.asInstanceOf
[MalFunction
]
29 "<function (fn* " + _pr_str(f
.params
) + " " + _pr_str(f
.ast
) + ")>"
37 def _pr_list(lst
: List
[Any
], print_readably
: Boolean
= true,
38 sep
: String
= " "): String
= {
39 lst
.map
{_pr_str(_
, print_readably
)}.mkString(sep
)