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

2016-12-19 Thread Ali via Digitalmars-d-learn
On Monday, 19 December 2016 at 14:09:47 UTC, pineapple wrote: 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:

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

2016-12-19 Thread Ali via Digitalmars-d-learn
On Monday, 19 December 2016 at 12:45:48 UTC, Nicholas Wilson wrote: Ah, oh well. It was nice in theory. Indeed. Thank you for trying Nicholas :) auto word = data.map!(reduce!max).array.map!"a[1]".array; you want auto word = data.map!"a[1]".map!(reduce!max).array; Problem max has to

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

2016-12-19 Thread pineapple via Digitalmars-d-learn
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

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

2016-12-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 19 December 2016 at 11:42:55 UTC, Ali wrote: On Monday, 19 December 2016 at 10:03:34 UTC, Nicholas Wilson wrote: [...] The seedless version without the typeof(a)(b[0], b[1]) hack (with default inited T) seems to crap out with: [...] Ah, oh well. It was nice in theory. [...]

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

2016-12-19 Thread Ali via Digitalmars-d-learn
On Monday, 19 December 2016 at 10:03:34 UTC, Nicholas Wilson wrote: On Monday, 19 December 2016 at 09:24:38 UTC, Ali wrote: On Monday, 19 December 2016 at 00:11:49 UTC, Nicholas Wilson wrote: [...] Ok so laziness stops as soon as sort is required on a range then? No. Because a lazy range

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

2016-12-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 19 December 2016 at 09:24:38 UTC, Ali wrote: On Monday, 19 December 2016 at 00:11:49 UTC, Nicholas Wilson wrote: [...] Ok so laziness stops as soon as sort is required on a range then? No. Because a lazy range is not random access, and therefore does not meet sorts requirement.

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

2016-12-19 Thread Ali via Digitalmars-d-learn
On Monday, 19 December 2016 at 00:11:49 UTC, Nicholas Wilson wrote: On Sunday, 18 December 2016 at 22:26:50 UTC, Ali wrote: 1. The first line with the splitting, I need to use .array three times. The last one I understand is because on "line 2" I alias T as the type of the data, and if I

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

2016-12-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 18 December 2016 at 22:26:50 UTC, Ali wrote: Hey, so I have this data file that has a list of a string of characters separated by new lines. The task is to find the most common letter in each column. Ie if file is: abc axy cxc Then the letters are a (column 1), x and c. I've

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

2016-12-18 Thread Ali via Digitalmars-d-learn
Hey, so I have this data file that has a list of a string of characters separated by new lines. The task is to find the most common letter in each column. Ie if file is: abc axy cxc Then the letters are a (column 1), x and c. I've written the code to do this at compile time. But I have a