Re: [racket] Knuth's algorithm S

2014-03-10 Thread Manfred Lotz
On Mon, 10 Mar 2014 15:09:28 -0400 Sean Kanaley wrote: > The current Racket algorithm has an error: > > (define counts (build-vector 10 identity)) > > This sets the counts to their indices, meaning e.g. 9 was pre-counted > 9 times. Switch the first line of the executable portion to run only >

Re: [racket] Knuth's algorithm S

2014-03-10 Thread Sean Kanaley
The current Racket algorithm has an error: (define counts (build-vector 10 identity)) This sets the counts to their indices, meaning e.g. 9 was pre-counted 9 times. Switch the first line of the executable portion to run only say 3 trials to see the effects. It should be: (define counts (make-v

Re: [racket] Knuth's algorithm S

2014-03-09 Thread Manfred Lotz
Justfor the records: I updated the version at http://rosettacode.org/wiki/Knuth%27s_algorithm_S#Racket -- Manfred Racket Users list: http://lists.racket-lang.org/users

Re: [racket] Knuth's algorithm S

2014-03-09 Thread Manfred Lotz
On Sun, 9 Mar 2014 16:44:06 -0400 Matthias Felleisen wrote: > > Consider moving the defines into main, and then run main: on my Mac, > this drives down the time by another 10%+: > Hm, interesting. Didn't make a difference on my Linux system. Anyway, overall I'm quite satisfied. I learned tha

Re: [racket] Knuth's algorithm S

2014-03-09 Thread Matthias Felleisen
Consider moving the defines into main, and then run main: on my Mac, this drives down the time by another 10%+: #! /bin/sh #| exec racket -t "$0" ${1+"$@"} |# #lang racket/base (provide main) (require racket/function) (define (main) (define (s-of-n-creator n) [define count 0] ; 'i' in

Re: [racket] Knuth's algorithm S

2014-03-09 Thread Manfred Lotz
On Sun, 09 Mar 2014 14:34:05 -0400 Neil Van Dyke wrote: > Manfred Lotz wrote at 03/09/2014 01:13 PM: > > There is a certain way the > > algorithm should be implemented (given at the top of the page). > > > > I haven't traced through the algorithm completely (and I have to run > out the door

Re: [racket] Knuth's algorithm S

2014-03-09 Thread Neil Van Dyke
Manfred Lotz wrote at 03/09/2014 01:13 PM: There is a certain way the algorithm should be implemented (given at the top of the page). I haven't traced through the algorithm completely (and I have to run out the door now), but looks like you might be able to replace the "(vector-copy vec)

Re: [racket] Knuth's algorithm S

2014-03-09 Thread Manfred Lotz
On Sun, 09 Mar 2014 13:00:04 -0400 Neil Van Dyke wrote: > Manfred Lotz wrote at 03/09/2014 12:34 PM: > [...] > > I had a look at the implementations of Knuth's algorithm S at > > rosetta code: http://rosettacode.org/wiki/Knuth's_algorithm_S#Racket > > > [...] > > Without profiling or trying

Re: [racket] Knuth's algorithm S

2014-03-09 Thread Neil Van Dyke
Manfred Lotz wrote at 03/09/2014 12:34 PM: [...] I had a look at the implementations of Knuth's algorithm S at rosetta code: http://rosettacode.org/wiki/Knuth's_algorithm_S#Racket [...] Without profiling or trying to understand the code: * Is all that vector copying really necessary? * Are

[racket] Knuth's algorithm S

2014-03-09 Thread Manfred Lotz
Hi there, I had a look at the implementations of Knuth's algorithm S at rosetta code: http://rosettacode.org/wiki/Knuth's_algorithm_S#Racket What baffles me is the fact that the Racket version is so slow. Running some sample on my laptop I have: Ruby: ruby kas.rb 0.57s user 0.01s system 99% cpu