I posted some sum-up on my github.
https://preview.tinyurl.com/y6sprdbq
On 10/4/20 6:50 AM, jerome wrote:
Thanks you very much Ali,
I will try to wrap my head around your inputs, and get a better
understanding of ranges in the process. I feel there is a lot of power
in D ranges, and like the hammer of Thor, I am not worthy yet :)
Just to elaborate a bit furthe
Thanks you very much Ali,
I will try to wrap my head around your inputs, and get a better
understanding of ranges in the process. I feel there is a lot of
power in D ranges, and like the hammer of Thor, I am not worthy
yet :)
On 9/12/20 11:25 AM, jerome wrote:
>
> import std.stdio : writeln;
> import std.algorithm.sorting;
>
> pure void quickSort(T) (T[] r)
> {
>if (r.length > 1)
>{
> size_t p = pivotPartition(r, r.length-1); //r[$-1] is swapped
to r[p]
>
> quickSo
On Tuesday, 8 July 2014 at 20:50:01 UTC, Nordlöw wrote:
Also related:
http://forum.dlang.org/thread/eaxcfzlvsakeucwpx...@forum.dlang.org#post-mailman.2809.1355844427.5162.digitalmars-d:40puremagic.com
On Tuesday, 8 July 2014 at 20:50:01 UTC, Nordlöw wrote:
I recall that Python's default sorting algorithm is related to
this, right?
https://en.wikipedia.org/wiki/Timsort
On Wednesday, September 14, 2011 14:36 bearophile wrote:
> Jonathan M Davis:
> > So, basically, you just want to shorten your code by wrapping array(func)
> > in a afunc function, and you think that this happens enough with map and
> > filter enough to merit putting these functions into Phobos.
>
Jonathan M Davis:
> So, basically, you just want to shorten your code by wrapping array(func) in
> a
> afunc function, and you think that this happens enough with map and filter
> enough to merit putting these functions into Phobos.
There is also the point 3) that you have not seen, plus the n
On Wednesday, September 14, 2011 07:46:37 bearophile wrote:
> Jonathan M Davis:
> > What would that gain you over passing the result of map or filter to
> > std.array.array?
>
> 1) The code gets shorter
> 2) The code gets a bit less noisy, because () add noise.
> 3) You use a single function inste
Jonathan M Davis:
> What would that gain you over passing the result of map or filter to
> std.array.array?
1) The code gets shorter
2) The code gets a bit less noisy, because () add noise.
3) You use a single function instead of two, so you reduce the number of chunks
your brain has to manage.
On Wednesday, September 14, 2011 06:09:52 bearophile wrote:
> %u:
> > i have qustion why filter can't return int[]
>
> Because a lazy filter is handy, you often don't need a real array result, a
> lazy sequence is enough. A lazy sequence avoids the memory allocation of
> the output array. In D pro
%u:
> i have qustion why filter can't return int[]
Because a lazy filter is handy, you often don't need a real array result, a
lazy sequence is enough. A lazy sequence avoids the memory allocation of the
output array. In D programs often the slowest parts are the memory allocations.
On the othe
On Wednesday, September 14, 2011 05:43:37 %u wrote:
> i have qustion why filter can't return int[]
> and if lambda return the last Expression without return keyword it would
> much cleaner
filter can't return int[]. filter does not alter the original array. It returns
a new range with only the e
i have qustion why filter can't return int[]
and if lambda return the last Expression without return keyword it would much
cleaner
On 09/14/2011 04:12 AM, Timon Gehr wrote:
On 09/14/2011 03:34 AM, hdsh wrote:
this my try
int[] quickSort(int[] arr) {
int[] result = quickSort(filter!(arr< arr[0])(arr)) ~ arr[0] ~
quickSort(filter!(arr> arr[0])(arr));
}
but it fail to compile
Note that this approach is an inefficient way o
On 09/14/2011 03:34 AM, hdsh wrote:
this my try
int[] quickSort(int[] arr) {
int[] result = quickSort(filter!(arr< arr[0])(arr)) ~ arr[0] ~
quickSort(filter!(arr> arr[0])(arr));
}
but it fail to compile
Note that this approach is an inefficient way of implementing a sorting
routine.
On Wednesday, September 14, 2011 01:34:34 hdsh wrote:
> this my try
>
> int[] quickSort(int[] arr) {
> int[] result = quickSort(filter!(arr < arr[0])(arr)) ~ arr[0] ~
> quickSort(filter!(arr > arr[0])(arr));
> }
>
> but it fail to compile
filter does not return an array. It returns a new ran
17 matches
Mail list logo