Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
lambda/prop in Racket
#lang racket
(struct proc/prop (f v)
#:property prop:procedure 0)
(define (procedure-property p [fail #f])
(if (proc/prop? p)
(proc/prop-v p)
fail))
(define-syntax-rule (lambda/prop #:prop e formals . body)
(proc/prop (λ formals . body)
e))
(provide lambda/prop procedure-property)
@samth
Owner

A sample interaction:

> (define f (lambda/prop #:prop 3 (x) x))
> f
#<procedure>
> (f 4)
4
> (procedure-property f)
3
> (procedure-property +)
#f
> (procedure-property + 'nope)
'nope
> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.