This commit is contained in:
Justin Ethier 2018-10-30 18:35:38 -04:00
parent 2a46a8f235
commit 9ba8467ba0

View file

@ -9,3 +9,20 @@
(set-cdr! a '(2))))))))
;; TODO: goal is a single cyc-seq containing all expressions as a single list
(define (convert sexp)
(define (flat sexp acc)
(write `(flat ,sexp)) (newline)
(cond
((null? sexp) acc)
((tagged-list? 'Cyc-seq sexp)
(flat (cdr sexp) acc))
((and (app? sexp)
(tagged-list? 'Cyc-seq (car sexp)))
(flat (cdar sexp) acc))
(else
(flat (cdr sexp) (cons sexp acc))))
)
(reverse
(flat sexp '(Cyc-seq))))
(write (convert sexp))