Implement step 9
[jackhill/mal.git] / gst / util.st
CommitLineData
d38ab263 1SequenceableCollection extend [
34aa5ced
VS
2 asDictionary [
3 | dict assoc |
4 dict := Dictionary new.
5 1 to: self size by: 2 do:
6 [ :i | dict add: (self at: i) -> (self at: i + 1) ].
7 ^dict
8 ]
9]
10
11String extend [
12 parse [
13 |text|
14 text := self copyFrom: 2 to: self size - 1.
15 text := text copyReplaceAll: '\"' with: '"'.
16 text := text copyReplaceAll: '\n' with: '
17'.
18 text := text copyReplaceAll: '\\' with: '\'.
19 ^text
20 ]
21
22 repr [
23 |text|
24 text := self copyReplaceAll: '\' with: '\\'.
25 text := text copyReplaceAll: '
26' with: '\n'.
27 text := text copyReplaceAll: '"' with: '\"'.
28 ^'"', text, '"'
29 ]
30]
6da164bd
VS
31
32BlockClosure extend [
33 valueWithExit [
34 ^self value: [ ^nil ]
35 ]
58e44bbb
VS
36
37 "HACK"
38 type [ ^#closure ]
39 value [ ^nil ]
6da164bd 40]