Some suggestions and questions ;-)
Suggestions:
- flat with an optional parameter of the level of flattening - (flat lst n)
Code: Select all
(set 'lst '(((1 2) (3 4)) ((5 6) (7 8))))
(flat lst 1) => ((1 2) (3 4) (5 6) (7 8))
(flat lst 2) => (1 2 3 4 5 6 7 8)
(flat lst 1) == (apply append lst)
(flat lst 2) == (apply append (apply append lst))
- opposite of empty? == (not (empty? x))
how to name it? - full? or not-empty?
Questions:
- how to convert an expression to a string the same way as the function 'print'? - except by not writing and reading it from a file???
Code: Select all
(define (exp-str e)
(device (open "tmp_file" "write"))
(print e)
(close (device))
(read-file "tmp_file"))
> (set 'e '(begin (set 'x 5) (+ x x)))
(begin
(set 'x 5)
(+ x x))
> (exp-str e)
"(begin \r\n (set 'x 5) \r\n (+ x x))"
> (println (exp-str e))
(begin
(set 'x 5)
(+ x x))
"(begin \r\n (set 'x 5) \r\n (+ x x))"
Fanda