Re: efficiency question

2002-02-11 Thread Jorge Adriano
On Monday 11 February 2002 02:10, Hal Daume III wrote: > So instaed of storing 1 and 2 in the list, it stores pointers to > them. The reason it does this is so that it makes it easy to generate > code for polymorhpic functions. (,) being boxed means that instead of > storing a pair of element, y

RE: efficiency question

2002-02-11 Thread Julian Seward (Intl Vendor)
Good luck! This is not for the faint of heart. J | -Original Message- | From: Jorge Adriano [mailto:[EMAIL PROTECTED]] | Sent: Sunday, February 10, 2002 7:18 PM | To: [EMAIL PROTECTED] | Subject: Re: efficiency question | | | On Sunday 10 February 2002 18:48, Kirsten Chevalier wrote: |

Re: efficiency question

2002-02-10 Thread Hal Daume III
I don't know of a reference, but here's the basic idea: if you have a polymorphic type (like [a]), and it's instantiated to [Int] (or whatever), instead of storing in memory a standard linked list representation like [1,2] = 1:2:[] = [1 x] /--> [2 x] /--> Nil \

Re: efficiency question

2002-02-10 Thread Jorge Adriano
On Sunday 10 February 2002 18:48, Kirsten Chevalier wrote: > I'd guess that it's not just that you have to apply the (,) constructor -- > it also has to do with the fact that the tuples it's constructing here are > boxed. could you elaborate a little more on that (boxed / unboxed) or provide a li

Re: efficiency question

2002-02-10 Thread Kirsten Chevalier
On Sat, Feb 09, 2002 at 12:01:02PM -0500, [EMAIL PROTECTED] wrote: > > > I'd say that's because in the second case you also got to apply the (,), > > besides the (+)/(-) constructor during the transversing... > > Am I right? > > opss... I meant to write: the (,) constructor besides the (+)/(-).

Re: efficiency question

2002-02-08 Thread Jorge Adriano
> I'd say that's because in the second case you also got to apply the (,), > besides the (+)/(-) constructor during the transversing... > Am I right? opss... I meant to write: the (,) constructor besides the (+)/(-)... J.A. ___ Glasgow-haskell-users ma

Re: efficiency question

2002-02-08 Thread Jorge Adriano
On Friday 08 February 2002 22:14, Hal Daume III wrote: > define > > test1 l = > let s1 = foldr (+) 1 l > s2 = foldr (-) 1 l > in (s1, s2) > > test2 l = > let s = foldr (\x (a,b) -> (x+a,x-b)) (1,1) l > in s > > why is test1 so much faster than test2 for long lists l (eg >

efficiency question

2002-02-08 Thread Hal Daume III
define test1 l = let s1 = foldr (+) 1 l s2 = foldr (-) 1 l in (s1, s2) test2 l = let s = foldr (\x (a,b) -> (x+a,x-b)) (1,1) l in s why is test1 so much faster than test2 for long lists l (eg [1..100])? replacing foldr with foldl makes it faster (of course), but