2016-02-18 18:24:26 +03:00
|
|
|
MalTypes := Object clone
|
|
|
|
|
|
|
|
nil malPrint := method(readable, self asString)
|
|
|
|
true malPrint := method(readable, self asString)
|
|
|
|
false malPrint := method(readable, self asString)
|
|
|
|
Number malPrint := method(readable, self asString)
|
|
|
|
|
|
|
|
// Io strings are of type Sequence
|
|
|
|
Sequence malPrint := method(readable,
|
2016-03-03 23:03:06 +03:00
|
|
|
if(readable, self asString asJson, self asString)
|
2016-02-18 18:24:26 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
MalSymbol := Object clone do (
|
|
|
|
val ::= nil
|
|
|
|
with := method(str,
|
|
|
|
self clone setVal(str)
|
|
|
|
)
|
|
|
|
malPrint := method(readable, val)
|
2016-03-03 23:03:06 +03:00
|
|
|
== := method(other, other isKindOf(MalSymbol) and (val == other val))
|
2016-02-18 18:24:26 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
MalKeyword := Object clone do (
|
|
|
|
val ::= nil
|
|
|
|
with := method(str,
|
|
|
|
self clone setVal(str)
|
|
|
|
)
|
|
|
|
malPrint := method(readable, ":" .. val)
|
2016-03-03 23:03:06 +03:00
|
|
|
== := method(other, other isKindOf(MalKeyword) and (val == other val))
|
2016-02-18 18:24:26 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
MalList := List clone do (
|
|
|
|
with := method(lst,
|
|
|
|
self clone copy(lst)
|
|
|
|
)
|
|
|
|
malPrint := method(readable,
|
|
|
|
"(" .. (self map(e, e malPrint(readable)) join(" ")) .. ")"
|
|
|
|
)
|
2016-03-03 23:03:06 +03:00
|
|
|
rest := method(MalList with(resend))
|
|
|
|
slice := method(MalList with(resend))
|
2016-02-18 18:24:26 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
MalVector := List clone do (
|
|
|
|
with := method(lst,
|
|
|
|
self clone copy(lst)
|
|
|
|
)
|
|
|
|
malPrint := method(readable,
|
|
|
|
"[" .. (self map(e, e malPrint(readable)) join(" ")) .. "]"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
MalMap := Map clone do (
|
|
|
|
withList := method(lst,
|
|
|
|
obj := self clone
|
|
|
|
k := nil
|
|
|
|
lst foreach(i, e,
|
|
|
|
if(i % 2 == 0,
|
|
|
|
k := e,
|
2016-03-01 18:46:12 +03:00
|
|
|
obj atPut(objToKey(k), e)
|
2016-02-18 18:24:26 +03:00
|
|
|
)
|
|
|
|
)
|
|
|
|
obj
|
|
|
|
)
|
2016-03-01 18:46:12 +03:00
|
|
|
objToKey := method(obj,
|
2016-02-18 18:24:26 +03:00
|
|
|
if(obj isKindOf(MalKeyword), "K_" .. (obj val), "S_" .. obj)
|
|
|
|
)
|
2016-03-01 18:46:12 +03:00
|
|
|
keyToObj := method(s,
|
2016-02-18 18:24:26 +03:00
|
|
|
if(s beginsWithSeq("K_"),
|
|
|
|
MalKeyword with(s exSlice(2)),
|
|
|
|
s exSlice(2)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
malPrint := method(readable,
|
2016-03-03 23:03:06 +03:00
|
|
|
"{" ..
|
|
|
|
(self map(k, v,
|
|
|
|
(keyToObj(k) malPrint(readable)) .. " " .. (v malPrint(readable))
|
2016-02-18 18:24:26 +03:00
|
|
|
) join(" ")) .. "}"
|
|
|
|
)
|
|
|
|
)
|