On 02/08/2013 03:19 AM, Laurent wrote:
On Fri, Feb 8, 2013 at 10:56 AM, Jens Axel Søgaard
<[email protected] <mailto:[email protected]>> wrote:
Try
[xs (if (list? xs) xs (sequence->list xs))])
and see what the new timings are.
Perfect! I'm glad it was so simple.
old mean:
cpu time: 3621 real time: 3621 gc time: 2613
494936207/10000000
new mean:
cpu time: 564 real time: 563 gc time: 0
494936207/10000000
my-mean:
cpu time: 512 real time: 515 gc time: 132
494936207/10000000
Thanks for catching this!
Had to explicitely cast xs to a list of reals:
(cast (if (list? xs) xs (sequence->list xs))
(Listof Real))
But shouldn't this patch be applied directly to sequence->list instead?
That's one option. Since lists are immutable, I can't think of why
having `sequence->list' sometimes not make a copy would be bad.
It might also be a good idea to handle vectors specially.
Another option is to do something with Typed Racket to get rid of this
type error, which makes the cast necessary:
Type Checker: Expected (Listof Real), but got
(U (Listof Real) (Pairof Any (Listof Any)))
I don't know why it does this, but there might be a good reason. Vincent?
Neil ⊥
____________________
Racket Users list:
http://lists.racket-lang.org/users