Re: [racket-users] handin server error

2016-09-11 Thread Eli Barzilay
On Wed, Sep 7, 2016 at 11:52 AM, Spencer Florence wrote: > This is a little bit of a hack and weakens the handin server security Your suggestion is pretty bad in that it's more significant than it looks. With it, you're allowing submission evaluation to read all files on the handin server. You

RE: [racket-users] Trouble with recursive lambda macros, using Y combinator

2016-09-11 Thread Jos Koot
After you have figured how to make recursive-lambda, you may want to figure out how to produce two mutually recursive functions. If, or rather I think 'when', you have more questions, don't hesitate to consult this list, for I am sure the PLT team and many others agree with this advice. Jos ___

RE: [racket-users] Trouble with recursive lambda macros, using Y combinator

2016-09-11 Thread Jos Koot
When using a macro, always think: "can I do the same without a macro?" You use the simple auto-applicator (lambda (x) (x x)). I suggest to use an applicative-order Y-combinator, such as: (define Y (λ (m) ((λ (f) (f f)) (λ (g) (m (λ (n) ((g g) n))) Now: ((Y (lambda (!) (lambda (n) (if (zero? n)

Re: [racket-users] Trouble with recursive lambda macros, using Y combinator

2016-09-11 Thread Gustavo Massaccesi
Just a comment about how to compare identifiers. In some cases, using equal? and syntax-e gives the wrong result. It's better to use free-identifier=? . For example, in this program we can use three methods to compare identifiers (there are more!). The program has two macros: clasify-id: shows th

Re: [racket-users] Re: Trouble with recursive lambda macros, using Y combinator

2016-09-11 Thread Jens Axel Søgaard
Hi Vasily, For completeness sake, note that you can use let-syntax and make the macro expander do the work of substitute-syntax. (require (for-syntax syntax/parse)) (define-syntax (recursion stx) (syntax-parse stx [(_recursion name (arg ...) expr) #'( (λ (x) (x x)) (λ (name)

[racket-users] Re: Trouble with recursive lambda macros, using Y combinator

2016-09-11 Thread Vasily Rybakov
Also thanks to Jens and Sam -- your examples is valuable, I learned from them (for example, how I can use (let) to bind variable that was defined before -- so it keeps previous binding in the definitions part of (let) but uses new binding in the body part of (let)). -- You received this messag

Re: [racket-users] Trouble with recursive lambda macros, using Y combinator

2016-09-11 Thread Vasily Rybakov
Hi, gustavo! Thanks for your answer, it was very helpful. So i rewrote my (substitute-term) macro like this: (define-syntax (substitute-term stx) (syntax-case stx () [(_ term-from term-to (body0 body ...)) #`#,(append (if (equal? (syntax-e #'body0) (syntax-e #'term-from))

Re: [racket-users] Trouble with recursive lambda macros, using Y combinator

2016-09-11 Thread Sam Caldwell
I think the simplest solution to your problem would be to use the *full* (for strict languages, I don't quite remember the name) Y-combinator rather than just self-application, which is what you have right now. Then you can just ditch `substitute-term` completely: -- (defin

Re: [racket-users] Trouble with recursive lambda macros, using Y combinator

2016-09-11 Thread Jens Axel Søgaard
Rather than use substitute-term you can bind name to do the right thing. For example: #lang racket (require (for-syntax syntax/parse)) (define-syntax (recursion stx) (syntax-parse stx [(_recursion name (arg ...) expr) #'( (λ (x) (x x)) (λ (name) (λ (arg ...)

Re: [racket-users] Trouble with recursive lambda macros, using Y combinator

2016-09-11 Thread Gustavo Massaccesi
In the first method, the problem is #%app https://docs.racket-lang.org/reference/application.html?q=%23%25app It's hidden by the default configuration of the macro stepper. Try changing the configuration to show it. The problem is that the expansion is: (substitute-term and or (and #t #f)) --->