Re: [racket] why does in-indexed / in-range slow down my program?

2013-01-20 Thread Matthew Flatt
At Sun, 20 Jan 2013 15:25:12 +0800, Limbo Peng wrote: > As the profiler shows, the most time-consuming part lies in the for-loop of > procedure "qf-connect!", and after a few experiments, I figure it out: it is > the "in-indexed" procedure that makes it slow. I replaced "in-indexed" with > sep

Re: [racket] variables within macros

2013-01-20 Thread Eli Barzilay
12 hours ago, Matthias Felleisen wrote: > > Eli's testing library is in some state of development. Some dev > people are using it. Yes, "some state" is a good description... I had a bunch of revisions that mainly make it easy to create new arrows for different kinds of testing. Three hours ag

Re: [racket] what's wrong with my code?

2013-01-20 Thread Danny Yoo
On Sun, Jan 20, 2013 at 6:50 PM, Robert Hume wrote: > I'm really stuck trying to figure this out. Any pointers are useful! > Here's the problem: > > f(n) = n if n<4 > and > f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) + 4f(n - 4) if n>= 4 > > Here's my solution so far -- any one know what I'm doing wr

Re: [racket] why does in-indexed / in-range slow down my program?

2013-01-20 Thread Limbo Peng
Hi Matthias, On 01/20, Matthias Felleisen wrote: > I can confirm a serious speed-up with the explicit vector-ref inside the for > loop instead of the for-loop lookup with (in-vector ...). I get from 20s to > 12s on my reasonably new (small) macair. > > When you look at the expansion, you see

Re: [racket] why does in-indexed / in-range slow down my program?

2013-01-20 Thread Limbo Peng
Hi Danny, On 01/20, Danny Yoo wrote: > Oh! I'm sorry. I didn't even look at that part of Peng's email, and > missed the comment on a faster algorithm. I had no idea what > "quick-find" or "quick-union" were. "quick-find" is a naive implementation of the union-find algorithm, which is presen

Re: [racket] Visitor Pattern and Racket

2013-01-20 Thread Harry Spier
Good point! I missed that. Cheers, Harry On Sun, Jan 20, 2013 at 8:39 PM, Stephen Bloch wrote: > > On Jan 20, 2013, at 7:55 PM, Harry Spier wrote: > >> Example 1: gives correct answer >> (define shish-c (new onion% [sh (new onion% [sh (new lamb% [sh (new >> skewer%)])])])) >> (send shish-c onl

Re: [racket] variables within macros

2013-01-20 Thread Asumu Takikawa
On 2013-01-20 17:26:33 -0500, Matthias Felleisen wrote: > (What is that? Link doesn't work.) Here is a working link: http://www.pltgames.com/ It's a programming competition held every month in which the contestants submit an implementation of a programming language that fits some theme. IOW, a

Re: [racket] what's wrong with my code?

2013-01-20 Thread Stephen Bloch
On Jan 20, 2013, at 8:50 PM, Robert Hume wrote: > I'm really stuck trying to figure this out. Any pointers are useful! Here's > the problem: > > f(n) = n if n<4 > and > f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) + 4f(n - 4) if n>= 4 > > Here's my solution so far -- any one know what I'm doin

Re: [racket] what's wrong with my code?

2013-01-20 Thread Jordan Johnson
For one thing, the question you are asking in the code, (> i 4) ;; i.e., i > 4 is not the same question you ask in your equations, n < 4 so, for starters, it would seem you need the two questions to be in agreement. Best, jmj -- Sent from my Android phone with K-9 Mail. Robert

[racket] what's wrong with my code?

2013-01-20 Thread Robert Hume
I'm really stuck trying to figure this out. Any pointers are useful! Here's the problem: f(n) = n if n<4 and f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) + 4f(n - 4) if n>= 4 Here's my solution so far -- any one know what I'm doing wrong? (define (f n) (define (f-iter result i) (if (> i 4)

Re: [racket] Visitor Pattern and Racket

2013-01-20 Thread Stephen Bloch
On Jan 20, 2013, at 7:55 PM, Harry Spier wrote: > Example 1: gives correct answer > (define shish-c (new onion% [sh (new onion% [sh (new lamb% [sh (new > skewer%)])])])) > (send shish-c only-onions? ) > > Example 2: gives incorrect answer > (define shish-c (new onion% [sh (new onion% [sh (new

Re: [racket] why does in-indexed / in-range slow down my program?

2013-01-20 Thread Danny Yoo
On Sun, Jan 20, 2013 at 5:23 PM, Matthias Felleisen wrote: > > I thought Limbo Peng wanted to measure the transliteration of some Go > algorithm. Wasn't there a remark somewhere that said "there is a faster > algorithm based on union-find"? Oh! I'm sorry. I didn't even look at that part of P

Re: [racket] Visitor Pattern and Racket

2013-01-20 Thread Harry Spier
On Sun, Jan 20, 2013 at 6:25 PM, Matthias Felleisen wrote: > > Normal OOPLs suffer from a lack of expressiveness. > OO programmers make up for this lack with programming > patterns. If you don't have first-class functions, > simulate them with the command pattern. If you don't > have functions but

Re: [racket] why does in-indexed / in-range slow down my program?

2013-01-20 Thread Matthias Felleisen
I thought Limbo Peng wanted to measure the transliteration of some Go algorithm. Wasn't there a remark somewhere that said "there is a faster algorithm based on union-find"? On Jan 20, 2013, at 7:11 PM, Danny Yoo wrote: >> As the profiler shows, the most time-consuming part lies in the for-l

Re: [racket] why does in-indexed / in-range slow down my program?

2013-01-20 Thread Danny Yoo
> As the profiler shows, the most time-consuming part lies in the for-loop of > procedure "qf-connect!", and after a few experiments, I figure it out: it is > the "in-indexed" procedure that makes it slow. I replaced "in-indexed" with > separate calls to "in-range" and "in-vector" - the running

Re: [racket] Visitor Pattern and Racket

2013-01-20 Thread Matthias Felleisen
On Jan 19, 2013, at 9:43 PM, Harry Spier wrote: > Does the Visitor pattern give something that collecting the methods in > the main class or using a mixin doesn't? Or do the class features of > Racket, particularly mixins make the Visitor Pattern superfluous? Yes. Normal OOPLs suffer from a

Re: [racket] why does in-indexed / in-range slow down my program?

2013-01-20 Thread Matthias Felleisen
I can confirm a serious speed-up with the explicit vector-ref inside the for loop instead of the for-loop lookup with (in-vector ...). I get from 20s to 12s on my reasonably new (small) macair. When you look at the expansion, you see the expected two-argument for-loop function with two argume

[racket] how to test syntax extensions

2013-01-20 Thread Matthias Felleisen
On Jan 20, 2013, at 6:35 AM, Tim Brown wrote: > Or are you starting a "design recipe" yourself with the "GOAL", "STEP > 1"...? > > The reason I ask is this: before I received your answer this evening, I > was going to re-attack the problem; either by taking the opportunity to > look at

Re: [racket] variables within macros

2013-01-20 Thread Matthias Felleisen
On Jan 20, 2013, at 6:35 AM, Tim Brown wrote: > Below, you use define-syntax-rule. Your example didn't seem to call for more. And define-syntax-rule is just a syntactic extension :-) for defining simplistic syntax extensions. Syntax objects are all under the hood. But you are correct. When

Re: [racket] performance problem in math/matrix

2013-01-20 Thread Ray Racine
Recall that last. Always measure at the command line . I'm seeing FlVector at 30% faster. #lang typed/racket (provide main) (require racket/unsafe/ops racket/fixnum racket/flonum) (define-type NF Nonnegative-Fixnum) (: matrix* : FlVector FlVector Index Index Index -> FlVector

Re: [racket] performance problem in math/matrix

2013-01-20 Thread Ray Racine
Modification of the above to use FlVector did not show a difference. On Sun, Jan 20, 2013 at 2:35 PM, Jens Axel Søgaard wrote: > 2013/1/20 Berthold Bäuml : > >> Ah! The Numpy example uses floats and not doubles. > > > > On my machine Numpy says it is using float64, hence, double. > > big1.dtype

Re: [racket] performance problem in math/matrix

2013-01-20 Thread Jens Axel Søgaard
2013/1/20 Berthold Bäuml : >> Ah! The Numpy example uses floats and not doubles. > > On my machine Numpy says it is using float64, hence, double. > big1.dtype.name -> float64 Sorry for the confusion. I am used to the Racket documentation were float means single precision, so I misinterpreted the

Re: [racket] performance problem in math/matrix

2013-01-20 Thread Neil Toronto
On 01/20/2013 11:14 AM, Jens Axel Søgaard wrote: 2013/1/20 Berthold Bäuml : With the ffi-binding example from Jens (thank you!) I get for the 1000x1000 multiply 450ms -- only 2x slower than Mathematica or Numpy. So integrating such a binding in math/matrix looks promising. Huh? I am surprised

Re: [racket] performance problem in math/matrix

2013-01-20 Thread Berthold Bäuml
On 20.01.2013, at 19:14, Jens Axel Søgaard wrote: > 2013/1/20 Berthold Bäuml : > >> With the ffi-binding example from Jens (thank you!) I get for the 1000x1000 >> multiply 450ms -- only 2x slower than Mathematica or Numpy. So integrating >> such a binding in math/matrix looks promising. > > Hu

Re: [racket] performance problem in math/matrix

2013-01-20 Thread Jens Axel Søgaard
2013/1/20 Berthold Bäuml : > With the ffi-binding example from Jens (thank you!) I get for the 1000x1000 > multiply 450ms -- only 2x slower than Mathematica or Numpy. So integrating > such a binding in math/matrix looks promising. Huh? I am surprised it is twice as slow. Ah! The Numpy example us

Re: [racket] performance problem in math/matrix

2013-01-20 Thread Matthias Felleisen
On Jan 20, 2013, at 12:48 PM, Berthold Bäuml wrote: > Nevertheless, my original motivation for the little test was to get an > impression of what performance could be achieved in purely Typed Racket for > numerical algorithms. Would it in principle be possible to come close to pure > C-code pe

Re: [racket] performance problem in math/matrix

2013-01-20 Thread Berthold Bäuml
On 20.01.2013, at 18:09, Neil Toronto wrote: > On 01/20/2013 07:09 AM, Jens Axel Søgaard wrote: >> Hi Berthold, >> >> 2013/1/20 Berthold Bäuml : >>> I tried a little test with mildly large Flonum matrices using math/matrix >>> in Typed >>> Racket. Two 1000x1000 dimensional matrices should be m

Re: [racket] variables within macros

2013-01-20 Thread Matthias Felleisen
On Jan 20, 2013, at 6:37 AM, Tim Brown wrote: >> On 01/19/2013 06:31 PM, Matthias Felleisen wrote: > [quoting depth out by one] >>> On Jan 18, 2013, at 12:36 PM, Tim Brown wrote: >>> Here is one way to justify this answer. You really may wish to >>> make define/test orthogonal to which testing f

Re: [racket] performance problem in math/matrix

2013-01-20 Thread Neil Toronto
On 01/20/2013 07:09 AM, Jens Axel Søgaard wrote: Hi Berthold, 2013/1/20 Berthold Bäuml : I tried a little test with mildly large Flonum matrices using math/matrix in Typed Racket. Two 1000x1000 dimensional matrices should be multiplied with (array- strictness #t). Running this in DrRacket resu

Re: [racket] Finding out values

2013-01-20 Thread Asumu Takikawa
On 2013-01-18 16:24:29 -0800, Brandon Mick wrote: >new to racket. im trying to find out what would ii get as a value if I >replace the s with “hello”  >its easier to do this with numbers where you would define s and give it a >number, but it won't work here.  I think I may be misun

[racket] Finding out values

2013-01-20 Thread Brandon Mick
(cond   [(<= (string-length s) 5) 10]   [(string=? s “hello”) 50]   [(string=? (substring s 1 4) “ell”) 25]   [else 130]) new to racket. im trying to find out what would ii get as a value if I replace the s with “hello”  its easier to do this with numbers where you would define s and give it a

Re: [racket] performance problem in math/matrix

2013-01-20 Thread Tobias Hammer
On Sun, 20 Jan 2013 15:09:42 +0100, Jens Axel Søgaard wrote: Note: Disable "Populate "compiled" directories (for faster loading)" to run it in DrRacket. To disable: Choose the language menu. Choose the menu item "Choose language". Click the button "advanced". The

Re: [racket] current-load/use-compiled and old .zo files

2013-01-20 Thread Robby Findler
I'm not sure of the ramifications of a change like that to current-load/use-compiled, but here are two thoughts that don't require that change: - use 'raco make' to recompile the files (instead of the racket script you have there) - set up your directories as collections using 'raco link' and the

[racket] current-load/use-compiled and old .zo files

2013-01-20 Thread Gustavo Massaccesi
Hi! Each time I install a new version of Racket I have a problem with the old .zo files compiled with the old version. I have the following program in my personal root racket folder that I use to compile all the files in all the subfolders: ;--- #lang racket/base (require compiler/compiler)

[racket] performance problem in math/matrix

2013-01-20 Thread Berthold Bäuml
Dear Neil, first I want to thank you for the great work the math package is. We hope to use it heavily in our "Racket in Robotics" environment we are currently developing. I tried a little test with mildly large Flonum matrices using math/matrix in Typed Racket. Two 1000x1000 dimensional matri

Re: [racket] variables within macros

2013-01-20 Thread Tim Brown
On 01/19/2013 06:31 PM, Matthias Felleisen wrote: [quoting depth out by one] On Jan 18, 2013, at 12:36 PM, Tim Brown wrote: Here is one way to justify this answer. You really may wish to make define/test orthogonal to which testing framework you use: -- rackunit -- test engine -- the Eli

Re: [racket] variables within macros

2013-01-20 Thread Tim Brown
Matthias, Thank you very much for your response. First, in the interests of full disclosure; I found a bug in my code -- there was a missing #` from one of my templates, which I found through luck rather than judgement. It'd be easy to claim that "all them parentheses in Racket just confuse me",