Re: [racket-dev] Feature request: Vector-sort
7 hours ago, Harry Spier wrote: > On Sun, Jul 29, 2012 at 6:12 PM, Eli Barzilay wrote: > > > Actually, the `sort' code uses a vector to do its work, which is > > initialized from the input list. But it doesn't help much to make it > > deal with vectors too, since the vector that is used for the sorting > > work needs to be bigger than the input -- so to sort a vector you'd > > still need to create a copy. Given that, you can usually just do the > > usual (list->vector (sort (vector->list v) <)). > > Thanks Eli. Thats in fact what I'm presently doing. i.e. vector->list > > Its on a vector of 26000 structs each consisting of 4 numbers and two > very short lists of numbers (0-2 or 3 numbers each). Then you only have the 26000 values to copy -- the contents of the vector is still the same in the list copy. -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] Feature request: Vector-sort
On Sun, Jul 29, 2012 at 6:12 PM, Eli Barzilay wrote: > Actually, the `sort' code uses a vector to do its work, which is > initialized from the input list. But it doesn't help much to make it > deal with vectors too, since the vector that is used for the sorting > work needs to be bigger than the input -- so to sort a vector you'd > still need to create a copy. Given that, you can usually just do the > usual (list->vector (sort (vector->list v) <)). Thanks Eli. Thats in fact what I'm presently doing. i.e. vector->list Its on a vector of 26000 structs each consisting of 4 numbers and two very short lists of numbers (0-2 or 3 numbers each). Harry _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] Feature request: Vector-sort
Also: (require data/heap) heap-sort! 2012/7/30, Eli Barzilay : > A few minutes ago, Harry Spier wrote: >> I would find a sort function for vectors very useful. > > Actually, the `sort' code uses a vector to do its work, which is > initialized from the input list. But it doesn't help much to make it > deal with vectors too, since the vector that is used for the sorting > work needs to be bigger than the input -- so to sort a vector you'd > still need to create a copy. Given that, you can usually just do the > usual (list->vector (sort (vector->list v) <)). > > -- > ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: > http://barzilay.org/ Maze is Life! > _ > Racket Developers list: > http://lists.racket-lang.org/dev > -- Inviato dal mio dispositivo mobile _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] Feature request: Vector-sort
A few minutes ago, Harry Spier wrote: > I would find a sort function for vectors very useful. Actually, the `sort' code uses a vector to do its work, which is initialized from the input list. But it doesn't help much to make it deal with vectors too, since the vector that is used for the sorting work needs to be bigger than the input -- so to sort a vector you'd still need to create a copy. Given that, you can usually just do the usual (list->vector (sort (vector->list v) <)). -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! _ Racket Developers list: http://lists.racket-lang.org/dev
[racket-dev] Feature request: Vector-sort
I would find a sort function for vectors very useful. Thanks, Harry Spier _ Racket Developers list: http://lists.racket-lang.org/dev