sort, .array and folding on immutable data (finding most common character in column of matrix)

pineapple via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Dec 19 06:09:47 PST 2016


On Monday, 19 December 2016 at 09:24:38 UTC, Ali wrote:
> Ok so laziness stops as soon as sort is required on a range 
> then? Ahh, because in place algorithms? Are there any plans in 
> D to make is to that you can output copies to collections so 
> that you could do something like filter.transpose.sort and just 
> have it output a modified copy?

This is a shortcoming of Phobos - here is a package of sorting 
algorithms including some that do not require their inputs to be 
mutable, random access, and/or finite:

https://github.com/pineapplemachine/mach.d/tree/master/mach/range/sort

The library is permissively licensed; feel free to take out 
whatever you need.

It's worth noting that giving up eagerness, random access, etc. 
often comes with a speed penalty. It may be more efficient just 
to copy the lazy things into memory first and then sort in-place, 
as you have been doing.



More information about the Digitalmars-d-learn mailing list