Re: Mergesort not working

2019-12-29 Thread SimonN via Digitalmars-d-learn
On Sunday, 29 December 2019 at 11:02:34 UTC, Adnan wrote: while (arr1_idx < arr1.length && arr2_idx < arr2.length) result ~= arr1[arr1_idx] < arr2[arr2_idx] ? arr1[arr1_idx++] : arr2[arr2_idx++]; Given an array, it just returns a 1 length array. What's causing this? This loop

Mergesort not working

2019-12-29 Thread Adnan via Digitalmars-d-learn
This is not entirely a D question, but I'm not sure what about my mergesort implementation went wrong. T[] merge(T)(T[] arr1, T[] arr2) { T[] result; result.reserve(arr1.length + arr2.length); ulong arr1_idx = 0, arr2_idx = 0; while (arr1_idx < arr1.length && arr2_idx <