Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Last active November 3, 2019 23:52
Show Gist options
  • Save chelseatroy/1dbc9d880c707f0a392e87af936a2322 to your computer and use it in GitHub Desktop.
Save chelseatroy/1dbc9d880c707f0a392e87af936a2322 to your computer and use it in GitHub Desktop.
Counts
(define (countdown n)
(cond ((= n 0) 'countdown-done)
(else
(display "Down ")
(displayln n)
(call-soon (lambda () (countdown (- n 1)))))))
(define (up stop)
(define (iter x)
(cond ((> x stop) 'up-done)
(else
(display "Up ")
(displayln x)
(call-soon (lambda () (iter (+ x 1)))))))
(iter 0))
(countdown 5)
; Down 5
; Down 4
; Down 3
; Down 2
; Down 1
(up 5)
; Up 1
; Up 2
; Up 3
; Up 4
; Up 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment