Re: [racket-users] Re: How to return summary from the inner loop?

2015-07-10 Thread Pierpaolo Bernardi
On Fri, Jul 10, 2015 at 11:40 PM, Pekka Niiranen wrote: > Thanks Sir, > > This was exactly what I tried to reason. > It never occured to me that parameter "failure" can be used > in both for/fold -constructs. I must fix once again my code. Sigh. I fixed a mistake, and renamed one of the two failu

Re: [racket-users] Re: How to return summary from the inner loop?

2015-07-10 Thread Stephen Chang
I understand now. I still claim that an (explicit) inner loop is not needed: (define (validate-ranges5 value-list low-list high-list) (for*/fold ([failures 0]) ([(lo hi) (in-parallel low-list high-list)] [v value-list] #:when (< lo v hi)) (printf "\n*

[racket-users] Re: How to return summary from the inner loop?

2015-07-10 Thread Pekka Niiranen
Thanks Sir, This was exactly what I tried to reason. It never occured to me that parameter "failure" can be used in both for/fold -constructs. About the problem (Stephen): value-list: '(5, 15, 25) low-list: '(1, 11, 21) high-list: '(10, 20, 30) I need to check the following 9 cases: LV

Re: [racket-users] How to return summary from the inner loop?

2015-07-10 Thread Pierpaolo Bernardi
On Fri, Jul 10, 2015 at 11:11 PM, Stephen Chang wrote: > Perhaps I don't understand the problem, but why is the inner loop necessary? He asked how to test each value against each of the limit pairs. I assume this is a simplified/demo problem and in the problem he really cares about there's a rea

Re: [racket-users] How to return summary from the inner loop?

2015-07-10 Thread Stephen Chang
Perhaps I don't understand the problem, but why is the inner loop necessary? By the way, you can use (printf ...) instead of (fprintf (current-output-port) ...) Would this work? (define (validate-ranges2 value-list low-list high-list) (for/sum ([v value-list] [lo low-list]

Re: [racket-users] How to return summary from the inner loop?

2015-07-10 Thread Pierpaolo Bernardi
On Fri, Jul 10, 2015 at 10:45 PM, Pierpaolo Bernardi wrote: > If I understand correctly the spec, this should do what you ask? which, fixing the typo, becomes: (define (validate-ranges value-list low-list high-list) (for/fold ((failures 0)) ((low (in-list low-list)) (h

Re: [racket-users] How to return summary from the inner loop?

2015-07-10 Thread Pierpaolo Bernardi
If I understand correctly the spec, this should do what you ask? (define (validate-ranges value-list low-list high-list) (for/fold ((failures 0)) ((low (in-list value-list)) (high (in-list high-list))) (for/fold ((failures 0)) ((value (in-list value-lis

[racket-users] How to return summary from the inner loop?

2015-07-10 Thread Pekka Niiranen
Hello users, I want to loop thru values and return the total number of failures instead of breaking out of loop as soon as the first failure is encountered. The code below works as intended: define (validate-order value-list low-list) ;; Checks whether all the values are all above list of low

Re: [racket-users] Diagnosing a segfault in production

2015-07-10 Thread Scott Bell
On Friday, July 10, 2015 at 12:05:55 AM UTC-7, Matthew Flatt wrote: > At Thu, 9 Jul 2015 10:08:53 -0700 (PDT), Scott Bell wrote: > > On Thursday, July 9, 2015 at 12:27:26 AM UTC-7, Matthew Flatt wrote: > > > At Wed, 8 Jul 2015 18:23:32 -0700 (PDT), Scott Bell wrote: > > > > On Wednesday, July 8, 20

Re: [racket-users] Diagnosing a segfault in production

2015-07-10 Thread Matthew Flatt
At Thu, 9 Jul 2015 10:08:53 -0700 (PDT), Scott Bell wrote: > On Thursday, July 9, 2015 at 12:27:26 AM UTC-7, Matthew Flatt wrote: > > At Wed, 8 Jul 2015 18:23:32 -0700 (PDT), Scott Bell wrote: > > > On Wednesday, July 8, 2015 at 4:05:20 PM UTC-7, Scott Bell wrote: > > > > On Wednesday, July 8, 2015