;;; portal-cross-save.lsp — write state to /tmp/cross.sexp

(define cross-int 777)
(define cross-list (list 'a 'b 'c 1 2 3))
(define cross-str "portal was here")
(define cross-fib
  (let loop ((a 0) (b 1) (i 0))
    (if (= i 20) a (loop b (+ a b) (+ i 1)))))

(define (cross-save filename)
  (let ((port (open-output-file filename)))
    (display ";; cross-impl portal (S-expression)\n" port)
    (display "(define cross-int " port) (write cross-int port) (display ")\n" port)
    (display "(define cross-list '" port) (write cross-list port) (display ")\n" port)
    (display "(define cross-str " port) (write cross-str port) (display ")\n" port)
    (display "(define cross-fib " port) (write cross-fib port) (display ")\n" port)
    (close-port port)))

(cross-save "/tmp/cross.sexp")
(display "saved cross-fib=") (display cross-fib) (newline)
