Created
February 5, 2024 14:43
-
-
Save ashiato45/4544ad27f1fa53643441ab9f75c60f8c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require racket/control) | |
; ((reset (shift k (lambda (state) 2))) 0) | |
(define (tick _) (shift k (lambda (state) ((k '()) (+ state 1))))) | |
(define (get _) (shift k (lambda (state) ((k state) state)))) | |
(define (run_state thunk) | |
((reset (let ((result (thunk '()))) | |
(lambda (state) result))) 0)) | |
(run_state tick) | |
(run_state get) | |
(run_state (lambda (_) | |
(tick '()) | |
(get '()) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment