[plt-scheme] New to PLT Redex. Need some help.
2009/10/16 Hari Prashanth <mail.prashanthkr at gmail.com>:
> Hi Everyone,
> I took the code given in the Redex website
> (http://redex.plt-scheme.org/lam-v.html) and made the following changes to
> it.
> 1. changed number pattern to string
>
> 2. Instead of +(in reduction-relation), I used string-append
>
> 3. (if0 0 e_1 e_2) to (if0 "true" e_1 e_2) and for the other case any other
> string except "true".
>
> And called traces like this
>
> (traces red
> (term
> ((λ (n)
> (if0
> n
> 1
> ((λ (x) (x x))
> (λ (x) (x x)))))
> (+ "2" "2"))))...
>
> But it did not reduce the expression in any way. Basically The output was
> just
> ((λ (n)
> (if0
> n
> 1
> ((λ (x) (x x))
> (λ (x) (x x)))))
> (+ "2" "2")).
>
> Where am I going wrong?
That should work. Probably there was some other small mistake
somewhere that is tripping you up.
My best advice for debugging Redex programs is to start playing with
redex-match. Make sure the expression above really is an "e". If it
isn't one, make a smaller and smaller example to understand why not.
Possibly, in this case, you needed a "1" in the middle of the term?
> How can I use symbol instead of string? When I used symbol, I got an error
> saying expected a non-terminal pattern but got one of Expr, Var, Val, Cntxt
> in symbol_1.
> Why did I get that error?
symbol isn't a built-in non-terminal. variable is, however.
Robby