Re: [Chicken-users] Good way to code the equivalent to this?

2008-09-24 Thread Kon Lovett
On Aug 25, 2008, at 12:50 PM, Tobia Conforto wrote: Matt Welland wrote: the tactic of loading lots of data into a hierarchy of hash arrays and then extracting the needed pieces in a myriad of ways, sometimes on the fly in a meeting with management nervously looking on :-) has been

Re: [Chicken-users] Good way to code the equivalent to this?

2008-08-25 Thread Tobia Conforto
Elf wrote: (define a (alist-hash-table (let loop ((i 0)) (if (fx= 25 i) '() (cons (cons (random 50) (random 50)) (loop (fx+ 1 i) =)) for an improvement in time (surprisingly), use (define a

Re: [Chicken-users] Good way to code the equivalent to this?

2008-08-25 Thread Elf
i got almost the same time as with my previous (incorrect) method by using a single hash table and an alist instead of a hash for the inner structure. memory usage isnt so good though. :( using a sparse multiple-alist structure seems to work nicely in small space and good time. i can post

Re: [Chicken-users] Good way to code the equivalent to this?

2008-08-25 Thread Elf
On Mon, 25 Aug 2008, Tobia Conforto wrote: Elf wrote: (define a (alist-hash-table (let loop ((i 0)) (if (fx= 25 i) '() (cons (cons (random 50) (random 50)) (loop (fx+ 1 i) =)) for an improvement in

Re: [Chicken-users] Good way to code the equivalent to this?

2008-08-25 Thread Tobia Conforto
Matt Welland wrote: the tactic of loading lots of data into a hierarchy of hash arrays and then extracting the needed pieces in a myriad of ways, sometimes on the fly in a meeting with management nervously looking on :-) has been tremendously useful for me. I for one am hoping that there

Re: [Chicken-users] Good way to code the equivalent to this?

2008-08-24 Thread felix winkelmann
Hi! This should perform much better and more closely resembles what you are trying to achieve. Note that Perl's data structures are bummed to absurd dimensions. We don't want that. cheers, felix -- (use extras) (define a (make-hash-table equal?)) (print filling ...) (do ((i 0 (add1 i)))

Re: [Chicken-users] Good way to code the equivalent to this?

2008-08-24 Thread Elf
my solution :) its faster (at least on chicken 3.3.something). timing on this box put this at just under 8s. -elf --- (use extras) (print filling ...) (define a (alist-hash-table (let loop ((i 0)) (if (fx= 25 i) '() (cons (cons

Re: [Chicken-users] Good way to code the equivalent to this?

2008-08-24 Thread Elf
for an improvement in time (surprisingly), use (define a (alist-hash-table (let loop ((i 0) (r '())) (if (fx= 25 i) r (loop (fx+ 1 i) (cons (cons (random 50) (random 50)) r

Re: [Chicken-users] Good way to code the equivalent to this?

2008-08-24 Thread Elf
i've been testing various solutions, which ill be happy to post if interested. all of them involve alist-hash-table. so far, the fastest solution, on average, has been list-tabluate to generate the list. (map! was a close contender, though.) the solution with the least GCs, on average, uses

Re: [Chicken-users] Good way to code the equivalent to this?

2008-08-24 Thread Elf
one final note: the time and memory usage for the list-tabulate, map!, and unfold solutions, on my box, are approximately 0.4s slower than perl, with slightly better memory usage stats (in chicken, that is). hope this helps. -elf ___

Re: [Chicken-users] Good way to code the equivalent to this?

2008-08-24 Thread Jim Ursetto
As a comparison, Felix's solution performs equivalently to my alist example when compiled, but runs much faster from the REPL. It also uses 9MB instead of 13MB. It's also simpler. On Sun, Aug 24, 2008 at 4:06 AM, felix winkelmann [EMAIL PROTECTED] wrote: This should perform much better and

Re: [Chicken-users] Good way to code the equivalent to this?

2008-08-24 Thread Jim Ursetto
Note that your solution effects a mapping of x - y, not from x - y - #t. That gets the job accomplished correctly, but doesn't reflect the original Perl code. For a fair comparison, you have to change the perl code to match, and then it runs in 1/3 of the memory and 1/2 the time of the original

Re: [Chicken-users] Good way to code the equivalent to this?

2008-08-24 Thread Matt Welland
Wow, thanks. That cut my run time in half to aprox 8..4 seconds. I'm using chicken 2.74 on this machine. I've tried 3.3 at a different machine but not seen much difference. Note that changing to non-hierarchical hashes breaks a lot of my existing code and is not exactly apples to apples with the

[Chicken-users] Good way to code the equivalent to this?

2008-08-23 Thread Matt Welland
My attempts all use gigs of memory and run 10x as long. #!/usr/bin/perl -w print Filling the array with 25 entries.\n; foreach $n (0 .. 25) { $x = int(rand(50)); $y = int(rand(50)); $a{$x}{$y}=1; } print Reading from the arrary 1 times\n; $hits=0; foreach $n (0 ..

Re: [Chicken-users] Good way to code the equivalent to this?

2008-08-23 Thread John Cowan
Matt Welland scripsit: My attempts all use gigs of memory and run 10x as long. So show us the problematic code, then. -- When I'm stuck in something boring John Cowan where reading would be impossible or(who loves Asimov too) rude, I often set up math problems for

Re: [Chicken-users] Good way to code the equivalent to this?

2008-08-23 Thread Matt Welland
Sorry for the overly brief problem statement. This is the two deep sparse array code I threw together. BTW, in the test code I am using numbers as the keys out of lazyness. The real code may use strings and or numbers. I'm using chicken 2.740 and 3.3.0 if it matters. I guess my question really