Re: [racket] is there any way to check whether two syntax objects have the same ... ?

2014-08-17 Thread Alexander D. Knauth
On Aug 17, 2014, at 2:29 PM, Carl Eastlund wrote: > Comparing lexical context is a very involved process. Remember that every > syntax object potentially carries context for an unbounded number of symbol > names at an unbounded number of phases, since context information can be > transferred

Re: [racket] is there any way to check whether two syntax objects have the same ... ?

2014-08-17 Thread Carl Eastlund
Comparing lexical context is a very involved process. Remember that every syntax object potentially carries context for an unbounded number of symbol names at an unbounded number of phases, since context information can be transferred freely. Comparing all of them for equivalence would be quite e

Re: [racket] is there any way to check whether two syntax objects have the same ... ?

2014-08-17 Thread Alexander D. Knauth
But those only work on identifiers, right? But would something like this work? (define (lexical-context=? s1 s2) (bound-identifier=? (datum->syntax s1 ‘x) (datum->syntax s2 ‘x))) Or would that miss something? On Aug 17, 2014, at 1:31 PM, Roman Klochkov wrote: > Maybe something of > > h

Re: [racket] is there any way to check whether two syntax objects have the same ... ?

2014-08-17 Thread Roman Klochkov
Maybe something of http://docs.racket-lang.org/reference/stxcmp.html ? Sat, 16 Aug 2014 23:32:10 -0400 от "Alexander D. Knauth" : >Is there any way to check whether two syntax objects have the same lexical >information, syntax-e (recursively), source location, properties, and whatever >else

Re: [racket] reference #:when clause in for/list?

2014-08-17 Thread Daniel Prager
Hi Mark 'in-value' -- which is new to me - thanks Sam! -- is cleaner than using a 'let' (or 'define') outside the for/list, hence preferable. Re-factoring my earlier example: (define (mersenne-primes-3 n) (for*/list ([i n] [c (in-value (sub1 (expt 2 i)))] #:when (pr

Re: [racket] reference #:when clause in for/list?

2014-08-17 Thread Mark Wallace
Thank Daniel and Sam! Below is a little conclusion: 1. When it comes to "for*/list", "in-values" can be used to introduce bindings just like "let". 2. "filter-map" can be a great alternative when "for/list" is considered. On 08/17/2014 07:59 PM, Sam Tobin-Hochstadt wrote: This is what 'in-v

Re: [racket] reference #:when clause in for/list?

2014-08-17 Thread Sam Tobin-Hochstadt
This is what 'in-value' is for. Sam On Aug 17, 2014 5:07 AM, "Mark Wallace" wrote: > Consider the following pseudocode: > > (for/list ([i ...] >#:when ) > ) > > Can I bind that expression E and reference in the body of "for/list"? > > If expression E takes lots of time to finish, w

Re: [racket] reference #:when clause in for/list?

2014-08-17 Thread Daniel Prager
Hi Mark Two ideas: 1. add a bit of state with for/list to save a reference to the expensive computation 2. filter-map keeps the reference more localised E.g. #lang racket (require math/number-theory) (define (mersenne-primes n) (let ([c 'dummy]) (for/list ([i n] #

[racket] reference #:when clause in for/list?

2014-08-17 Thread Mark Wallace
Consider the following pseudocode: (for/list ([i ...] #:when ) ) Can I bind that expression E and reference in the body of "for/list"? If expression E takes lots of time to finish, we would not want to compute it again :). I understand that there are workarounds like first colle