Re: [racket] Using new packages, step-by-step

2014-03-12 Thread Joe Gilray
Thanks Matt. I am up and running. -Joe On Sun, Mar 9, 2014 at 7:23 PM, Matthew Flatt wrote: > At Wed, 5 Mar 2014 16:31:39 -0800, Joe Gilray wrote: > > I've used dherman's memoize for years. To use it I added: > > > > (require (planet dherman/memoize:3:1))

[racket] Using new packages, step-by-step

2014-03-09 Thread Joe Gilray
I've used dherman's memoize for years. To use it I added: (require (planet dherman/memoize:3:1)) and changed "define" to "define/memo" Now that I installed Racket 6.0, I'd like to use the memoize that is referenced at http://pkgs.racket-lang.org/. Can someone give me a step-by-step guide on ho

Re: [racket] Where to learn advanced programming skills?

2013-07-26 Thread Joe Gilray
he correct answer, you can always find a better/faster/cleaner solution in the forums (fora?). It is quite humbling. -Joe On Fri, Jul 26, 2013 at 4:05 AM, Tim Brown wrote: > On 24/07/13 18:29, Joe Gilray wrote: > >> By the time you get to problem #60 you will have built a little

Re: [racket] Using future and touch

2013-07-26 Thread Joe Gilray
[f1 (future (λ () (find-progressive-num2 1 1000 4 lim ht)))] >>>> [f2 (future (λ () (find-progressive-num2 2 1000 4 lim ht)))] >>>> [f3 (future (λ () (find-progressive-num2 3 1000 4 lim ht)))]) >>>> (+ (find-progressive-num2 4 1000 4 lim ht) (touch f1) (

Re: [racket] Using future and touch

2013-07-25 Thread Joe Gilray
e code you are metering? Thanks, -Joe On Thu, Jul 25, 2013 at 5:40 PM, Robby Findler wrote: > hashes are definitely not future-safe, unfortunately. > > Robby > > > On Thu, Jul 25, 2013 at 6:50 PM, Joe Gilray wrote: > >> Here is an update: >> >> I rewrot

Re: [racket] Using future and touch

2013-07-25 Thread Joe Gilray
untime to make those future safe! > > Robby > > > On Wed, Jul 24, 2013 at 11:34 PM, Joe Gilray wrote: > >> So I should write my own (gcd ) and (square? ) functions? >> >> I can try that, but isn't there a simple way to use threads? >> >>

Re: [racket] Using future and touch

2013-07-25 Thread Joe Gilray
tion is to write your own version of it, unfortunately. > > -James > > >> On Wed, Jul 24, 2013 at 11:34 PM, Joe Gilray wrote: >> >> > So I should write my own (gcd ) and (square? ) functions? >> > >> > I can try that, but isn't ther

Re: [racket] Using future and touch

2013-07-24 Thread Joe Gilray
the futures. square-number? is implemented in TR and if you take it, > you find that integer-sqrt also blocks the futures. I'm not sure if those > functions can be made to run safely in futures or not. > > Robby > > > On Wed, Jul 24, 2013 at 7:26 PM, Joe Gilray wrote: > >&g

[racket] Using future and touch

2013-07-24 Thread Joe Gilray
I have a ProjectEuler problem that I wanted to speed up so I thought I would try to speed it up with future / touch. I tried the following: ; function that searches for progressive numbers for a given range of b values (define (find-progressive-num b-start b-end b-incr lim) (for/sum ([b (in-ran

Re: [racket] Where to learn advanced programming skills?

2013-07-24 Thread Joe Gilray
Hi Ben, If you want to practice and need some fun problems to work on, I recommend going to projecteuler.net and solving problem #1. Then read the forum to see how others solved it. Solve problem #2... rinse and repeat. By the time you get to problem #60 you will have built a little toolbox of

Re: [racket] Roadmap for Racket

2013-07-17 Thread Joe Gilray
Racket2 name suggestion: (add1 racket) :-) -Joe On Wed, Jul 17, 2013 at 7:29 AM, John Griffin wrote: > I meant "LATER when it arrives", not "LATE when it arrives." > > Thanks again, > -JG > > On Jul 17, 2013, at 9:56 AM, John Griffin wrote: > > Matthew, Robby, Jay, Sam, and Matthias, > > Th

Re: [racket] Racket v5.3.5

2013-06-27 Thread Joe Gilray
d try it under "Racket -l drracket". Thanks again, -Joe On Wed, Jun 26, 2013 at 3:42 PM, Robby Findler wrote: > Oh, I recall that thread. That makes it sound like a problem at a lower > layer where my suggestion won't help. > > Thanks (and sorry), > Robby > >

Re: [racket] Racket v5.3.5

2013-06-26 Thread Joe Gilray
Robby, Please look at this thread: http://www.mail-archive.com/users@racket-lang.org/msg16636.html Thanks, -Joe On Wed, Jun 26, 2013 at 11:51 AM, Joe Gilray wrote: > Yes, Good Idea, stay tuned... I will see if I can make it happen. > > -Joe > > > On Tue, Jun 25, 2013

Re: [racket] Racket v5.3.5

2013-06-26 Thread Joe Gilray
good and hung. There is some chance that that will print out some > context information about an infinite loop that DrRacket has fallen into > and that information might let us get a toe-hold on the bug. > > Robby > > > On Tue, Jun 25, 2013 at 1:19 PM, Joe Gilray wrote: > >

Re: [racket] Racket v5.3.5

2013-06-25 Thread Joe Gilray
don't, by any chance, type a ] with either alt-gr down or with some > other modifier? > > Robby > > > On Mon, Jun 24, 2013 at 7:13 PM, Joe Gilray wrote: > >> FYI, I've been getting DrRacket "not responding"s quite a bit on both >> 64-bit and 3

Re: [racket] Racket v5.3.5

2013-06-24 Thread Joe Gilray
ewhere else. -- Matthias > > > > > On Jun 21, 2013, at 12:56 PM, Joe Gilray wrote: > > How does one use the code in the "realm" collection? > > It is through (require ...) or just by copying the source? > > thanks, > -joe > > > On Tue, J

Re: [racket] Racket v5.3.5

2013-06-21 Thread Joe Gilray
How does one use the code in the "realm" collection? It is through (require ...) or just by copying the source? thanks, -joe On Tue, Jun 18, 2013 at 4:20 AM, Eli Barzilay wrote: > Racket version 5.3.5 is now available from > > http://racket-lang.org/ > > This is a special-purpose release

Re: [racket] Realm of Racket

2013-06-20 Thread Joe Gilray
I ordered it from Amazon. FYI, They have a comparable discount and free slow shipping (or free fast shipping with Amazon prime). -Joe On Tue, Jun 18, 2013 at 7:27 PM, Matthias Felleisen wrote: > > Thanks! > > On Jun 18, 2013, at 7:36 PM, Cosme Enmanuel Zamudio Salazar wrote: > > Congratulation

Re: [racket] Racket 5.3.4, 32-bit slow?

2013-06-04 Thread Joe Gilray
Hi again Danny, Very interesting note, thanks for the details. The problem is a slightly easier version of one the ProjectEuler.net problems (see here: http://projecteuler.net/problem=210) Basically the hard part of the problem is finding the grid points that fall in a circle with origin at (125

Re: [racket] Racket 5.3.4, 32-bit slow?

2013-06-04 Thread Joe Gilray
Hi Danny, Yes, makes perfect sense, hmmm... there's probably a way to avoid so many sqrt calls. How do you like Go? How is the performance on this code? Thanks, -joe On Tue, Jun 4, 2013 at 12:59 PM, Danny Yoo wrote: > Some of the involved numbers are bigger than can be represented in 32 > b

[racket] Racket 5.3.4, 32-bit slow?

2013-06-04 Thread Joe Gilray
The following code runs in reasonable time (about 5s) on 64-bit 5.3.4, but takes about 20x as long on 32-bit. I adapted this code from some scheme code on the PE forum. Thoughts? Thanks, -Joe (define (euler210) (define limit (expt 10 8)) (define ldiv4 (quotient limit 4)) (define ldiv8 (qu

Re: [racket] Racket v5.3.4

2013-05-08 Thread Joe Gilray
Thanks Eli. The installation "feels" faster, but I have seen a couple of random "not responding"s so far on a W7/32bit OS. Tonight I will try out W7/64bit and OSX. -joe On Wed, May 8, 2013 at 9:46 AM, Eli Barzilay wrote: > Racket version 5.3.4 is now available from > > http://racket-lang.o

Re: [racket] Thanks for Math

2013-04-21 Thread Joe Gilray
Yes, the math library is awesome. Many thanks. Richard, what are you using it for? (if you are liberty to say, of course). -joe On Sat, Apr 20, 2013 at 8:28 PM, Richard Cleis wrote: > Thanks for the math library. I started using some of the linear algebra > functions for my paid programming,

Re: [racket] random big nat, please

2013-04-11 Thread Joe Gilray
Really fun stuff. Thanks Neil. -Joe On Mon, Apr 8, 2013 at 2:10 PM, Robby Findler wrote: > Thanks! What a great message! > > Robby > > > On Mon, Apr 8, 2013 at 2:47 PM, Neil Toronto wrote: > >> Moving this to the list because it seems general-interest-y. >> >> >> On 04/02/2013 11:08 AM, Robby

Re: [racket] Planet2 questions

2013-04-04 Thread Joe Gilray
If I am a consumer of packages do I need to make any changes to use the new system? For example, I have code that has: (require (planet dherman/memoize:3:1)) (require (planet jaymccarthy/dijkstra:1:2)) What do I do to "point" at planet2? Thanks, -joe On Thu, Apr 4, 2013 at 8:18 AM, Jay McCart

Re: [racket] Racket v5.3.3

2013-02-26 Thread Joe Gilray
on to microsoft" box came up. It mentioned 3 files, a .txt file, a .xml file and a .mdmp file. the txt file and .xml files are short but seem uninteresting the mdmp file is about 2 MB. Let me know if you want to see any of these files. Regards, -Joe On Mon, Feb 25, 2013 at 10:59 AM,

Re: [racket] Racket v5.3.3

2013-02-25 Thread Joe Gilray
drracket > > then, when DrRacket get stuck again, there's a small chance that typing > Ctl-C in the terminal will produce a useful context listing. It's > probably worth a try, anyway. > > At Mon, 25 Feb 2013 10:29:19 -0800, Joe Gilray wrote: > > No problem, Matth

Re: [racket] Racket v5.3.3

2013-02-25 Thread Joe Gilray
-bit Windows, but I > haven't yet done enough work on it. I'm still looking for a way to > provoke crashes, and the thought that the debugger might be relevant is > helpful. > > At Mon, 25 Feb 2013 10:08:59 -0800, Joe Gilray wrote: > > I had a problem with my test code t

Re: [racket] Racket v5.3.3

2013-02-25 Thread Joe Gilray
do seem to occur more often in the debugger. Regards, -Joe On Tue, Feb 19, 2013 at 7:10 PM, Joe Gilray wrote: > Has anyone else noticed that the 64-bit version on Win7 is faster than the > 32-bit version? > > I thought that the longer pointers were supposed to slow down execution. >

[racket] Fun with math lib - named let

2013-02-23 Thread Joe Gilray
Just had some fun using the new math library to solve ProjectEuler problems #108 and #110. Here's one of my functions: ; function which solves for the lowest number which has more than the passed number of diophantine reciprocals ; n is multiplied by 2 to account for symmetrical (equivalent) solu

[racket] Debugging query - lists cut off in variables pane

2013-02-23 Thread Joe Gilray
If you have a long list say: (define aaa '(1 2 3 4 5 6 7 8 9 10 11 12 13 ... 1000)) In the variables pane of the debugger it will show *aaa* => (1 2 3 4 5 6 7 8 9 10 11 and the right hand side will be cut off (not wrapped). To see more you can stretch the pane, but there is no scroll bar. I'd

Re: [racket] Error while debugging

2013-02-23 Thread Joe Gilray
Are using 5.3.3 64-bit version under Win 7? I'm seeing "random" crashes on that version, seems worse in the debugger, BTW. -Joe On Tue, Feb 19, 2013 at 1:28 AM, wrote: > There's no error message. The program just falls down. Win displays > message "Program stop working wait? quit?" someth

Re: [racket] Math library kudos

2013-02-20 Thread Joe Gilray
prime-strong-pseudo-single?)? Thanks again for a very useful set of functions! -joe On Wed, Feb 20, 2013 at 11:24 AM, Jens Axel Søgaard wrote: > Hi Joe, > > 2013/2/20 Joe Gilray : > > Racketeers, > > > > Thanks for putting together the fantastic math library. It

Re: [racket] Math library kudos

2013-02-19 Thread Joe Gilray
ilnis wrote: > FYI, log gamma is another fast way to calculate the number of combinations > if you want to deal with really big numbers. > > On Tue, Feb 19, 2013 at 7:28 PM, Joe Gilray wrote: > >> Racketeers, >> >> Thanks for putting together the fantastic ma

Re: [racket] Racket v5.3.3

2013-02-19 Thread Joe Gilray
Has anyone else noticed that the 64-bit version on Win7 is faster than the 32-bit version? I thought that the longer pointers were supposed to slow down execution. BTW, still seeing some crashes on 64-bit and none on 32-bit Thoughts? -Joe On Sat, Feb 16, 2013 at 10:49 AM, Joe Gilray wrote

[racket] Math library kudos

2013-02-19 Thread Joe Gilray
Racketeers, Thanks for putting together the fantastic math library. It will be a wonderful resource. Here are some quick impressions (after playing mostly with math/number-theory) 1) The functions passed all my tests and were very fast. If you need even more speed you can keep a list of primes

Re: [racket] Racket v5.3.3

2013-02-16 Thread Joe Gilray
Thanks Racketeers, I am still seeing crashes on Win7 64bit with 5.3.3. About every 6 hours or so I get "program not responding" (doesn't seem to correlate to anything in particular). Haven't seen it on Win7 32 bit. -Joe On Fri, Feb 15, 2013 at 12:53 PM, Eli Barzilay wrote: > Racket version

Re: [racket] Racket v5.3.2

2013-02-02 Thread Joe Gilray
FYI. Since starting with 5.3.2 I've seen two DrDracket crashes (Windows7 - 64 bit). Hard to determine the cause in both case I believe I had just clicked in the definitions pane when it hung and Windows told me that DrRacket was not responding. I have spent about 4 hours in DrRacket, so the cras

Re: [racket] Racket v5.3.2

2013-02-01 Thread Joe Gilray
bugging a little easier. thanks, -joe On Fri, Feb 1, 2013 at 5:27 AM, Robby Findler wrote: > > > > On Fri, Feb 1, 2013 at 1:30 AM, Joe Gilray wrote: > >> Thanks Eli, >> >> Ran all my code under 5.3.2 - looking good. I'm definitely interested in >> lo

Re: [racket] Racket v5.3.2

2013-01-31 Thread Joe Gilray
Thanks Eli, Ran all my code under 5.3.2 - looking good. I'm definitely interested in looking into the math lib. BTW, ever since 5.3.1 (I think), the debugger acts a little different, in the variables pane it only shows the beginning of lists. How can I see the entire list? If I require planet

[racket] minimum spanning tree

2012-12-02 Thread Joe Gilray
I searched the mailing list archives and didn't find any references to an implementation of a minimum spanning tree algorithm. I've implemented Prim's algorithm years ago in C#, but I was surprised not to find anything on Planet or the archive. If I create an implementation, where should I "publi

Re: [racket] Call by Name

2012-11-27 Thread Joe Gilray
Thanks to all for the workable solutions. I quickly implemented Ian's idea and it is working for me... thanks again! Here is a little background so you can better educate me: As I've been learning Racket I've created a file called play.rkt that contains useful code I've learned. Its primary pur

[racket] Call by Name

2012-11-27 Thread Joe Gilray
Hi, I have a bunch of functions with known names. How do I call them? For example. If I have functions named "test1", "test2", ... "test999" I'd like to call them all: (define (bigtest) (define base "test") (for ([n (range 1 1000)]) (call-by-name (string-append base (number->string n)))

Re: [racket] A small little random tutorial

2012-10-21 Thread Joe Gilray
I had it explained to me this way once. On your first pick to *want* to pick an incorrect door. That way when you switch you will switch to the correct door. What is the probability of picking an incorrect door on the first pick? 2/3. -Joe On Sat, Oct 20, 2012 at 9:07 PM, Gregory Woodhouse wro

Re: [racket] Problem with case

2012-09-18 Thread Joe Gilray
Thanks for the question, Kieron. It got me to look up case and think a little about its usage. I'd like to see a discussion of the tradeoffs between cond & case & match and how each is best used. Thanks, -joe On Tue, Sep 18, 2012 at 7:07 AM, Kieron Hardy wrote: > Thanks for the info guys, now

Re: [racket] My new Racket blog....

2012-09-02 Thread Joe Gilray
Hi Jay, OK, that helped. Now it cannot find: "/usr/share/dict/words" -Joe On Sat, Sep 1, 2012 at 11:05 AM, Jay McCarthy wrote: > On Thu, Aug 30, 2012 at 6:10 PM, Joe Gilray wrote: > > Hi Jay, > > > > Since your post, I've been reading and thoroughly

Re: [racket] Teach Yourself Racket (version 0.1)

2012-09-02 Thread Joe Gilray
Hi Prabhakar, Really excellent material. Thanks for doing this. Here are some suggestions after a first read-through: Intro: "languages" should be "language" 1.7: the last paragraph would be nicely illustrated with a short example (list of lists, maybe?) 2.1: some explanation of the "alternativ

Re: [racket] My new Racket blog....

2012-08-30 Thread Joe Gilray
Hi Jay, Since your post, I've been reading and thoroughly enjoying your blog... thank you! Some newbie questions and comments: 1) I clicked the "download" button on your boggle posting and read it into DrRacket (5.3). When I hit run I get: ..\..\..\Program Files\Racket\collects\mred\private\sn

Re: [racket] Project Euler now has a "Racket" language

2012-08-17 Thread Joe Gilray
Hi Tim, I solved the first 200+ in C#. Recently I switched to Racket and have (so far) solved the first 99 problems. My life has never been sweeter... I've lost 20 lbs, my hair reverted back from gray and I'm suddenly much more suave and interesting! Racket: it'll change your life!! -Joe On F

Re: [racket] rackunit vs test-engine

2012-08-08 Thread Joe Gilray
nergy 1) 9e+16 1e+15))) > > (module+ test > (time (run-test (make-test-suite "both" (list test1 test2) > > > -- Matthias > > > > On Aug 8, 2012, at 5:50 PM, Joe Gilray wrote: > > Sorry Matthias, but I don't understand the mechanics. I've rea

Re: [racket] rackunit vs test-engine

2012-08-08 Thread Joe Gilray
org/docs/html/rackunit/api.html#(def._((lib._rackunit/main..rkt)._check-~3d))> (to-energy 1) 9e+16 1e+15)) I know that running the file in DrRacket will run the tests, but I'd like to time them. Thanks (again!), -Joe On Wed, Aug 8, 2012 at 1:46 PM, Matthias Felleisen wrote: > >

Re: [racket] rackunit vs test-engine

2012-08-08 Thread Joe Gilray
and when you wish by loading the proper module. > > Please search for an earlier post of mine where I explain a specific > arrangement of separate modules to make all of this convenient. > > With submodules, you can stick these test suites into submodules and > require those in

Re: [racket] rackunit vs test-engine

2012-08-07 Thread Joe Gilray
;t allowed and I will need to group the tests? Thanks again, -Joe On Tue, Aug 7, 2012 at 6:00 PM, Matthias Felleisen wrote: > > On Aug 7, 2012, at 8:24 PM, Joe Gilray wrote: > > > Now that 5.3 is out, I've been reading about submodules and their > support for testing. In

[racket] rackunit vs test-engine

2012-08-07 Thread Joe Gilray
Now that 5.3 is out, I've been reading about submodules and their support for testing. In the past I used test-engine/racket-tests for testing. Can someone please give me a rundown of when to use rackunit and advantages/disadvantages of test-engine and rackunit? Thanks, -Joe

Re: [racket] First RacketCon 2011 video now available

2012-08-06 Thread Joe Gilray
Very nice! Thanks again. On Mon, Aug 6, 2012 at 5:43 PM, Stevie Strickland wrote: > Why yes, you may! The playlist, which is being updated as videos get > uploaded, is at: > > http://www.youtube.com/playlist?list=PL00E2E52739AC707F > > HTH, > Stevie > > On Aug 6, 2

Re: [racket] First RacketCon 2011 video now available

2012-08-06 Thread Joe Gilray
Thank you sir!... may I have some more? On Sat, Aug 4, 2012 at 11:52 AM, Rodolfo Carvalho wrote: > I'm super happy with the videos! And I sure I'm not alone ;) > > Thanks! > > Rodolfo Carvalho > > > > On Fri, Aug 3, 2012 at 10:03 PM, Greg Hendershott < > greghendersh...@gmail.com> wrote: > >> Thi

Re: [racket] Is eval very slow?

2012-07-19 Thread Joe Gilray
; => cpu time: 21110 real time: 21125 gc time: 436 > > > > > - Original Message - > *From:* Joe Gilray > *To:* Racket mailing list > *Sent:* Thursday, July 19, 2012 7:15 AM > *Subject:* [racket] Is eval very slow? > > Hi, > > I've written some

[racket] Is eval very slow?

2012-07-18 Thread Joe Gilray
Hi, I've written some code that uses eval: (define ops (list * / + -)) (define digits '(1 2 3 4 5)) (for ([dl (combinations 4 digits)]) (define lst '()) (for ([d (permute-all dl)]) (for* ([o1 ops] [o2 ops] [o3 ops]) (unless (and (eq? o1 /) (zero? (eval (list o2 (second

[racket] First use of a PLaneT package

2012-06-02 Thread Joe Gilray
Hi Racketeers, I added "*(require (planet dherman/memoize:3:1))"* to my code and have been successful in using define/memo, but since this is my first experience with PLaneT, I have some basic questions. 1) The install took about 20 minutes, is this normal or did something go awry (see messages b

Re: [racket] Help with filter-map

2012-05-28 Thread Joe Gilray
Thanks Jens for explaining the filter-map idiom and for the fun code example, very enlightening! -Joe On Mon, May 28, 2012 at 1:34 AM, Jens Axel Søgaard wrote: > 2012/5/28 Joe Gilray : > > I created some Racket solutions to ProjectEuler #71. Below is one that > uses > &

[racket] Help with filter-map

2012-05-27 Thread Joe Gilray
I created some Racket solutions to ProjectEuler #71. Below is one that uses filter and map: (define (euler71c) (numerator (apply max (filter (λ (n) (> (/ 3 7) n)) (map (λ (n) (/ (floor (/ (* n 3) 7)) n)) (stream->list (in-range 2 100))) 1) I thought I might speed it up by using filter-

Re: [racket] question about classes

2012-05-20 Thread Joe Gilray
40 AM, Matthias Felleisen wrote: > > On May 20, 2012, at 11:02 AM, Joe Gilray wrote: > > 1) Is what I've done an abomination? Am I simply abusing inheritance? > > > You are changing a part of a recursive nest of methods, which is what > inheritance is all about. > &

Re: [racket] question about classes

2012-05-20 Thread Joe Gilray
solution in this case, but it might be to pass the > value for `start' into `build-repeat' instead of trying to get the > value from the `start' field within `build-repeat'. > > At Sun, 20 May 2012 02:06:35 -0700, Joe Gilray wrote: > > I'm tryin

[racket] question about classes

2012-05-20 Thread Joe Gilray
I'm trying to learn to use classes in Racket. I did some successful simple experiments then moved on to inheritance. When I try to use the code below, the following code: (new sqrtcontfrac% [sqrval i]) leads to the message: sqr: expected argument of type ; given # Why isn't start being inherit

Re: [racket] release date for RacketCon videos?

2012-05-15 Thread Joe Gilray
Sam, Any update on RacketCon videos? Any way that Jeff's advisor can be prevailed upon to at least ask him to release the videos as they are? Thanks, -Joe On Wed, Apr 4, 2012 at 8:44 AM, Sam Tobin-Hochstadt wrote: > On Wed, Apr 4, 2012 at 11:35 AM, Greg Hendershott > wrote: > > I do think the

Re: [racket] The value of a language

2012-05-09 Thread Joe Gilray
To follow up on Matthias's thread: 2025: Companies are forced to install soundproofing when the voices of NL programmers in their 4'x4' cubicles bother their neighbors in the "social marketing" department 2035: A command reportedly issued by a POTUS "with a bad cold" to national SIRI causes the f

Re: [racket] idiomatic and fast

2012-04-28 Thread Joe Gilray
Wow, thanks for all the creative solutions! After many years of programming, I'm still so floored by what a creative and artistic endeavor it is... and like all artistic endeavors, over time one develops a certain taste and style. Certain solutions really appeal over others. Thanks again, learni

[racket] idiomatic and fast

2012-04-28 Thread Joe Gilray
Hi, I'm trying to come up with the most idiomatic way to generate triangle numbers that is also fast: (for/list ([i (in-range 2 22)]) (for/sum ([j (in-range i)]) j)) works but is slow because it regenerates the sums each time (define s 0) (for/list ([i (in-range 1 21)]) (set! s (+ s i)) s) is

Re: [racket] making Racket code more idiomatic

2012-04-18 Thread Joe Gilray
t; (expt base exp) 400)))] [i (in-range 2 401)]) (* i exp))) (- (length lst) (length (remove-duplicates lst)) 2012/4/18 Joe Gilray > Thanks for more food for thought. > > Cristian, I really like the form of your solution with the answer being

Re: [racket] making Racket code more idiomatic

2012-04-18 Thread Joe Gilray
99) >>> (for/sum ([d '(2 3 5 6 7 10)]) >>> (let loop ([lst '()] [exp 1]) >>> (if (> (expt d exp) 100) >>> (- (length lst) (length (remove-duplicates lst))) >>> (loop (for/fold ([lst lst]) ([i (in

Re: [racket] making Racket code more idiomatic

2012-04-17 Thread Joe Gilray
Cristian, One more thing, since for*/fold in your code only takes one accumulator, you don't need "values" at all. Makes the code even shorter! -Joe On Tue, Apr 17, 2012 at 12:54 PM, Joe Gilray wrote: > Hi Guys. > > Thanks for the education on for/fold and for*/

Re: [racket] making Racket code more idiomatic

2012-04-17 Thread Joe Gilray
t))) > > (loop (for/fold ([lst lst]) ([i (in-range 2 101)]) > > (cons (* i exp) lst)) > > (add1 exp))) > > > > At Tue, 17 Apr 2012 09:45:50 -0700, Joe Gilray wrote: > >> Hi, > >> > >&

[racket] making Racket code more idiomatic

2012-04-17 Thread Joe Gilray
Hi, To continue our conversation about creating idiomatic Racket code, here is some code I wrote last night to solve projecteuler.net problem #29: (define (euler29a) ; calculate 99^2 - duplicates (- (sqr 99) (for/sum ([d '(2 3 5 6 7 10)]) (let ([lst '()]) (l

Re: [racket] extra exercises

2012-04-16 Thread Joe Gilray
You are so right, Neil, I've been slowly learning more and more idiomatic Racket. Some things I've picked up: 1) avoid mutators (see above) 2) avoid side-affects, use return values 3) Use list comprehensions and other powerful procedures (for*, for/list, foldl, map, etc) 4) Don't be afraid to wr

Re: [racket] extra exercises

2012-04-16 Thread Joe Gilray
The problems at projecteuler.net are also a good way to get up to speed with a new language. -Joe On Mon, Apr 16, 2012 at 8:58 AM, Danny Yoo wrote: > > Im following the book Desiging programms second edition. > > I'm now at the end of chapter 2 and I get the idea I need some extra > > exercises

Re: [racket] (if ...) form without an else

2012-04-11 Thread Joe Gilray
Hi Lothar, The if statement in Racket always requires three arguments: (if test-expr then-expr else-expr) if you only want a

Re: [racket] First try with hashes in Racket

2012-04-03 Thread Joe Gilray
-length ht 98) 259 -Joe On Mon, Apr 2, 2012 at 9:40 PM, Neil Van Dyke wrote: > Joe Gilray wrote at 04/03/2012 12:00 AM: > >> *The bad news*: it still feels a little clunky. It has a lot of >> imperative statements and the memoization in the hash table feels too much >

Re: [racket] First try with hashes in Racket

2012-04-02 Thread Joe Gilray
. Any more help? Thanks again! -Joe On Mon, Apr 2, 2012 at 12:37 AM, Neil Van Dyke wrote: > Joe Gilray wrote at 04/02/2012 12:44 AM: > >> 1) [,,,] >> >> > (define ggg (make-hash (list '(1 4 >> > > Instead of '(1 4) , which is a list, you want a

[racket] First try with hashes in Racket

2012-04-01 Thread Joe Gilray
Hi, On ProjectEuler #14 I tried to use hashes for the first time and although I got it to work, I feel like my use of hashes needs help: (define (euler14) (define ht (make-hash)) (hash-set! ht 1 1) (define start-longest-chain 1) (define longest-chain 1) (for ([i (in-range 2 100)])

Re: [racket] do loops in racket, also srfi/25 query

2012-03-27 Thread Joe Gilray
Thanks (again) Rodolfo, Do people use the srfi/25 arrays much? Or is the normal practice to simply use vector with a little "reference arithmetic"? -Joe On Mon, Mar 26, 2012 at 9:26 PM, Rodolfo Carvalho wrote: > Hi Joe, > > > On Mon, Mar 26, 2012 at 21:22, Joe Gilray wr

Re: [racket] do loops in racket, also srfi/25 query

2012-03-26 Thread Joe Gilray
2 1) apply: expects type as 3rd argument, given: '#(1 2 3 4 5 6 7 8 9); other arguments were: # # -Joe On Mon, Mar 26, 2012 at 2:11 AM, Pierpaolo Bernardi wrote: > On Mon, Mar 26, 2012 at 01:31, Joe Gilray wrote: > > Hi Tom, > > > > thanks for the comments. > > > >

Re: [racket] do loops in racket, also srfi/25 query

2012-03-25 Thread Joe Gilray
cases are similar. > > (define (across) > (for*/fold ([mx 0]) > ([i (in-range 0 20)] > [j (in-range 0 17)]) > (max mx (* (get i j) >(get i (+ j 1)) >(get i (+ j 2)) > (get i (+ j 3

[racket] do loops in racket, also srfi/25 query

2012-03-24 Thread Joe Gilray
I was playing around with ProjectEuler #11 and found a lisp solution and adapted it to Racket. Part of the solution had code like the following to find products of values in a 20x20 vector. (define (prod-of-vec-lines-of-length-4 v ix iy dx dy) (do ([p 1 (* p (if (in-vector? x y 20 20) (vector-r

Re: [racket] Racket style question

2012-03-21 Thread Joe Gilray
Hi Rodolfo, In this case though, printf will never return #f so "and" is equivalent to "begin", right? -Joe On Wed, Mar 21, 2012 at 2:30 PM, Rodolfo Carvalho wrote: > On Wed, Mar 21, 2012 at 17:21, Joe Gilray wrote: > >> Hi Tim, >> >> Than

Re: [racket] Racket style question

2012-03-21 Thread Joe Gilray
Hi Tim, Thanks for sharing your code. Quick, newby question: why do you use "and" instead of "begin" in your progress function? I've seen others do this as well (of course, Eli's "(and...)" idiom above is a whole different animal... and very cool. Thanks, -Joe On Wed, Mar 21, 2012 at 10:01 AM,

Re: [racket] Racket style question

2012-03-19 Thread Joe Gilray
te. > > Robby > > On Mon, Mar 19, 2012 at 1:34 PM, Joe Gilray wrote: > > Hi again Rodolfo, > > > > After a some mods, I ran several trials with n = 1 on my ancient > laptop > > and got the following results: > > > > (define (pythagorean-trip

Re: [racket] Racket style question

2012-03-19 Thread Joe Gilray
te that pre-defining a-limit didn't improve performance here either) I'm learning a lot from these examples. I'd love to see other idioms as well. Thanks, -Joe On Mon, Mar 19, 2012 at 12:44 AM, Rodolfo Carvalho wrote: > On Mon, Mar 19, 2012 at 04:35, Joe Gilray wrote: >

Re: [racket] Racket style question

2012-03-19 Thread Joe Gilray
Thanks Rodolfo and Eli for the education, very elegant solutions. I really like the clever use of the "(and (right-triangle? a b c) (list a b c" idiom. I had to look up in-value... unfortunately the manual is a bit sparse there, but I got the gift by running some examples... thanks. After go

[racket] Racket style question

2012-03-18 Thread Joe Gilray
Hi, I created the following code from some scheme I found on ProjectEuler.net (problem #9): (define (right-triangle? a b c) (= (+ (* a a) (* b b)) (* c c))) (define (pythagorean-triple n) (let loop-a ([a 1]) (let loop-b ([b (add1 a)]) (let ([c (- n a b)]) (if (<= c b)

Re: [racket] spirit of Racket?

2012-03-11 Thread Joe Gilray
Impressive improvement! Thanks Matthias. -Joe On Sun, Mar 11, 2012 at 4:14 PM, Matthias Felleisen wrote: > > I believe the code below cuts your running time to one third. -- Matthias > > #lang racket > > (require srfi/13) > > (define (euler4e) > (for*/fold ([greatest 0]) ([first (in-range 101

Re: [racket] spirit of Racket?

2012-03-11 Thread Joe Gilray
numbers are the numbers 100-999 > (define (pe-004) > (for*/fold ([greatest 0]) >([first (in-range 101 1000)] > [second (in-range 101 1000)] > #:when (palindrome? (* first second))) >(max greatest (* first second > > Justin > > On Sun, Mar 11, 2012 a

[racket] spirit of Racket?

2012-03-11 Thread Joe Gilray
Hi, I'm redoing the ProjectEuler problems to learn Racket (great fun!). Below are three solutions to PE#4. Which is most in the spirit of Racket? Of course, I'd love to see solutions that are more idiomatic too. Is there a better way that doesn't use "for" at all? Thanks! -Joe ; function tha

Re: [racket] streams, recursion and running out of memory

2012-02-22 Thread Joe Gilray
nk we also confirm that you have a better machine than I :-) -joe On Wed, Feb 22, 2012 at 8:40 AM, Rodolfo Carvalho wrote: > Hello Joe, > > > 2012/2/22 Joe Gilray > >> Hi Matthew, >> >> Thanks for your help. I really can't even pretend to understand the >>

Re: [racket] streams, recursion and running out of memory

2012-02-21 Thread Joe Gilray
void an N-deep nesting at the point where O(N^2) > behavior would kick in. > > I haven't studied the code enough to be certain that my explanation is > right, but when I see surprising space consumption with laziness and > undelimited continuations, my first guess is that undelimite

Re: [racket] DrRacket crashes

2012-02-20 Thread Joe Gilray
Hi Neal, The code is not using tail recursion, but my test code is allocating and deallocating large structures about 20 times before the crash. I am limiting memory for DrRacket to 1GB (the system has 3GB). DrRacket was using about 800MB the last time I checked before the crash. Note that it d

[racket] DrRacket crashes

2012-02-20 Thread Joe Gilray
I've been playing with large streams, lists and vectors of primes for the past couple of days and have seen the following behavior on my Win7 system 3 times: In the middle of a memory intensive operation the disk will start to rattle and the system will be slower (I measured with (time) about a 30

[racket] streams, recursion and running out of memory

2012-02-20 Thread Joe Gilray
Hi, I created an infinite stream of primes (using this interesting article: http://matthias.benkard.de/journal/116) I tried to create a prime-pi function: (define (prime-pi n) (let loop-count ([candidate-stream prime-stream]) (if (> (stream-first candidate-stream) n) 0

Re: [racket] static variables question

2012-02-19 Thread Joe Gilray
Hi Rodolfo, Thanks for the suggestion. I ended up reading quite a bit about generators and found this very appropriate and interesting page: http://matthias.benkard.de/journal/116. -Joe On Sun, Feb 19, 2012 at 7:05 PM, Rodolfo Carvalho wrote: > On Mon, Feb 20, 2012 at 00:55, Joe Gilray wr

Re: [racket] static variables question

2012-02-19 Thread Joe Gilray
Hi Rodolfo, Thanks for the suggestions. Your re-factoring (no pun intended) of the conds really cleaned things up. Much appreciated. About the unnecessary loops, good point, I simply changed to starting with end set to 10 instead of 1000 and I think that helps a lot. I know that there are othe

Re: [racket] Style mistakes (was: static variables question)

2012-02-19 Thread Joe Gilray
I love it! Ron Paul Middle school, 2024, Ms. Anderson's 5th grade: "But Teacher, when I ran 'StyleNazi' like you told us to, it just came back with: 'here's a phone card, call your mother...' " -Joe On Sun, Feb 19, 2012 at 6:10 PM, Eli Barzilay wrote: > 20 minutes ago, Rodolfo Carvalho wro

  1   2   >