the specific case I had in mind was near this (let ([unless? odd?]) (for/sum ([x '(1 2 3 4 5)] #:unless (uless? x)) x)) ;6
but as long as one is defaulting #:unless PLUS #unless is common to all the for's across some arbitrary scope, ideally one could elide it from each of the for's within that scope. your current-unless looks a good candidate for another place. On Saturday, August 4, 2018 at 3:47:42 PM UTC-4, Greg Hendershott wrote: > > Do you mean that in something like this: > > (for/sum ([x '(1 2 3 4 5)] > #:unless (odd? x)) > x) ;6 > > You have many occurrences of the `(odd? x)` and you'd like to define > that in one place that you can vary? > > If so: > > First, if they're in the same local scope, you could use `let`: > > (let ([unless? odd?]) > (for/sum ([x '(1 2 3 4 5)] > #:unless (uless? x)) > x)) ;6 > > Or (same difference) if they're in the same function definition, you > could use a function parameter: > > (define (f unless?) > (for/sum ([x '(1 2 3 4 5)] > #:unless (unless? x)) > x)) > (f odd?) ;6 > > Or -- and maybe this is what you're asking? -- you could define a > Racket parameter: > > (define current-unless? (make-parameter (const #f))) > > (define (f) > (for/sum ([x '(1 2 3 4 5)] > #:unless ((current-unless?) x)) > x)) > > (parameterize ([current-unless? odd?]) > (f)) ;6 > > I think this is the best you can do; the `for` macros don't provide a > parameter to inject an #:unless clause. > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.