[racket] Sweet expressions; or making it easier to introduce Racket to me and my coworkers :-)
On Mon, Jul 25, 2011 at 11:20 PM, David Van Horn <dvanhorn at ccs.neu.edu> wrote:
>
> Cute! Thanks for the cool planet package. Here's a slightly larger example
> using Redex, adapted from redex/examples/arithmetic.rkt:
>
> #lang planet asumu/sweet racket
> require rename-in(redex [term quote])
>
> define-language lang
> e n
> δ1(e)
> δ2(e e)
> δ1 √ add1 sub1
> δ2 + - * /
> E hole
> δ1(E)
> δ2(e E)
> δ2(E e)
> n number
>
> define v
> reduction-relation lang
> { √(n) --> ,sqrt('n) }
> { add1(n) --> ,add1('n) }
> { sub1(n) --> ,sub1('n) }
> { +(n_1 n_2) --> ,+('n_1 'n_2) }
> { -(n_1 n_2) --> ,-('n_1 'n_2) }
> { *(n_1 n_2) --> ,*('n_1 'n_2) }
> { /(n_1 n_2) --> ,/('n_1 'n_2) }
>
> define -->_v
> context-closure v lang E
>
> traces -->_v '-(*(√(36) /(1 2)) +(1 2))
>
If only Redex could typeset in this syntax :)