Skip to content

Instantly share code, notes, and snippets.

View petrolifero's full-sized avatar

João Pedro Abreu de Souza petrolifero

View GitHub Profile
@seckcoder
seckcoder / gist:9204855
Last active May 22, 2023 04:29
implementation of exception, generator and coroutine based on continuation
#lang racket
; Implementations and examples are inspired by Matt Might's blog posts:
; http://matt.might.net/articles/programming-with-continuations--exceptions-backtracking-search-threads-generators-coroutines/
; Note I didn't just copy the code. I implemented it independently, so it looks a lot different from Matt's code.
(define (current-continuation)
(call/cc (lambda (k)
(k k))))
(define (exception)