Last active
April 1, 2019 05:26
-
-
Save kmicinski/c3f3eda4928d1fd29f0bdcda5e6e5f8e to your computer and use it in GitHub Desktop.
Find all possible redexes of a given lambda term
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 | |
(define (find-redexes e) | |
(match e | |
[`(λ (,x) ,body) (find-redexes body)] | |
[(? symbol? x) (void)] | |
[`((λ (,x) ,body) ,arg) | |
(begin | |
(display "I found this redex!\n") | |
(pretty-print e) | |
(find-redexes body) | |
(find-redexes arg))] | |
[`(,e0 ,e1) | |
(begin | |
(find-redexes e0) | |
(find-redexes e1))])) | |
(define example '((λ (x) ((λ (y) (x y)) x)) (λ (z) (z z)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment