git @ Cat's Eye Technologies Decoy / 106e32e
Depict improper lists. Chris Pressey 1 year, 9 months ago
3 changed file(s) with 21 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
3232 * A module system of sorts
3333 * Some libraries, supplied as modules in this system
3434
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
3636 of some support functions and/or macros.
3737
3838 Why?
126126 ----
127127
128128 * Comparison operators on strings -- what does Scheme do for this?
129 * Attempt to load modules from module path if module path supplied.
129130 * Start on the compiler framework.
130131 * `if`
131 * Depict improper lists.
132132 * `=`
8585 elseif sexp.class == Cons then
8686 s = s .. "("
8787 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
92101 end
93102 s = s .. ")"
94103 return s
2626
2727 (cons (quote thing) (quote (rest)))
2828 ===> (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)
2935
3036 `car` extracts the head of a list.
3137