;; Experiment with persistent continuations
;; read-char* : like read-char but ignores \r and \n
(define (read-char* [in (current-input-port)])
(let ([v (read-char in)])
[(#\newline #\return) (read-char* in)]
;; A simple interactive counter.
;; Type + to increment, - do decrement, anything else to stop.
;; When stopped, the counter returns a continuation which
;; let's you continue using your counter from where you stopped.
(define (counter [init 0])
[else (displayln "bye...") (e k)]))))))
(define sqlc (sqlite3-connect #:database 'memory))
(query-exec sqlc "create table counters (continuation)")
(query-exec sqlc "insert into counters values (?)"
(with-input-from-string "++++-+--." (thunk (counter))))
(query-list sqlc "select continuation from counters")