Depict improper lists.
Chris Pressey
1 year, 9 months ago
32 | 32 |
* A module system of sorts
|
33 | 33 |
* Some libraries, supplied as modules in this system
|
34 | 34 |
|
35 | |
Again, these would not be too difficult to suppoort in Scheme by means
|
|
35 |
Again, these would not be too difficult to support in Scheme by means
|
36 | 36 |
of some support functions and/or macros.
|
37 | 37 |
|
38 | 38 |
Why?
|
|
126 | 126 |
----
|
127 | 127 |
|
128 | 128 |
* Comparison operators on strings -- what does Scheme do for this?
|
|
129 |
* Attempt to load modules from module path if module path supplied.
|
129 | 130 |
* Start on the compiler framework.
|
130 | 131 |
* `if`
|
131 | |
* Depict improper lists.
|
132 | 132 |
* `=`
|
85 | 85 |
elseif sexp.class == Cons then
|
86 | 86 |
s = s .. "("
|
87 | 87 |
s = s .. depict(sexp.head())
|
88 | |
while sexp.tail() and sexp.tail().class == Cons do
|
89 | |
s = s .. " "
|
90 | |
s = s .. depict(sexp.tail().head())
|
91 | |
sexp = sexp.tail()
|
|
88 |
sexp = sexp.tail()
|
|
89 |
local done = false
|
|
90 |
while not done do
|
|
91 |
if sexp.class == Cons then
|
|
92 |
s = s .. " "
|
|
93 |
s = s .. depict(sexp.head())
|
|
94 |
sexp = sexp.tail()
|
|
95 |
elseif sexp == Nil then
|
|
96 |
done = true
|
|
97 |
else
|
|
98 |
s = s .. " . " .. depict(sexp)
|
|
99 |
done = true
|
|
100 |
end
|
92 | 101 |
end
|
93 | 102 |
s = s .. ")"
|
94 | 103 |
return s
|
26 | 26 |
|
27 | 27 |
(cons (quote thing) (quote (rest)))
|
28 | 28 |
===> (thing rest)
|
|
29 |
|
|
30 |
`cons` can be used to create an improper list.
|
|
31 |
(The `.` syntax for improper lists is not supported in the reader though.)
|
|
32 |
|
|
33 |
(cons (quote thing) (quote rest))
|
|
34 |
===> (thing . rest)
|
29 | 35 |
|
30 | 36 |
`car` extracts the head of a list.
|
31 | 37 |
|