On Saturday, 1 August 2015 at 09:35:53 UTC, DLearner wrote:
Does the D language set in stone that the first element of an
array _has_ to be index zero?
Wouldn't starting array elements at one avoid the common
'off-by-one' logic error, it does
seem more natural to begin a count at 1.
Actually,
On Monday, 6 February 2017 at 18:57:17 UTC, Ali Çehreli wrote:
I think it's now std.algorithm.chunkBy. Please fix Rosetta
Thank you!
I fixed, but anyway it works incorrect (it doesn't any changes):
Code: https://rosettacode.org/wiki/Natural_sorting#D
Result: http://pastebin.com/hhSB4Vpn
like
On Monday, 6 February 2017 at 18:55:19 UTC, pineapple wrote:
One reason for zero-based indexes that isn't "it's what we're
all used to" is that if you used one-based indexes, you would
be able to represent one fewer index than zero-based, since one
of the representable values - zero - could no
On 02/06/2017 03:00 PM, Bastiaan Veelo wrote:
> In "Numerical Recipes in C", section 1.2, Press et al. propose an easy
> solution using an offset pointer:
>
> float b[4], *bb;
> bb = b - 1;
>
> Thus bb[1] through bb[4] all exist, no space is wasted nor is there a
> run-time overhead.
>
> I have t
(There is an honest question in the end, please read on.)
All good reasons set aside, both in favour and against 0-based
arrays, the only reason that is relevant to me right now is that
we are seriously looking into translating close to a million
lines of foreign code to D, from a language tha
On 02/06/2017 12:17 PM, Paolo Invernizzi wrote:
> I'm missing Bearophile...
> (and btw, Kenji)
Anybody knows where they are? Rust? Haskell? Something else? :)
Ali
On 02/05/2017 12:33 PM, berni wrote:
With X not known at compile time:
auto arr = new int[][](X,X);
for (int i=0;i
Is there anything better for this? I mean, the program will fill the
array with zeroes, just to overwrite all of them with -1. That's wasted
execution time and doesn't feel D-ish
One another way is use something like this:
import std.array, std.algorithm, std.stdio;
auto arr = uninitializedArray!(int[][])(ROWS,COLS);
arr.each!"a[]=-1";
writeln(arr);
Dne 6. 2. 2017 8:21 PM napsal uživatel "berni via Digitalmars-d-learn" <
digitalmars-d-learn@puremagic.com>:
> On Sunday, 5
On Monday, 6 February 2017 at 18:57:17 UTC, Ali Çehreli wrote:
On 02/06/2017 08:43 AM, Dmitry wrote:
Found this https://rosettacode.org/wiki/Natural_sorting#D
but there is error on ".groupBy!isDigit" (Error: no property
'groupBy'
for type 'string').
I think it's now std.algorithm.chunkBy.
On Sunday, 5 February 2017 at 21:14:33 UTC, Daniel Kozak wrote:
http://stackoverflow.com/questions/24600796/d-set-default-value-for-a-struct-member-which-is-a-multidimensional-static-arr/24754361#24754361
Dne 5.2.2017 v 21:33 berni via Digitalmars-d-learn napsal(a):
With X not known at compile
On 02/06/2017 08:43 AM, Dmitry wrote:
Found this https://rosettacode.org/wiki/Natural_sorting#D
but there is error on ".groupBy!isDigit" (Error: no property 'groupBy'
for type 'string').
I think it's now std.algorithm.chunkBy. Please fix Rosetta Code as
well. Thanks! :)
Ali
On Monday, 6 February 2017 at 18:55:19 UTC, pineapple wrote:
One reason for zero-based indexes that isn't "it's what we're
all used to" is that if you used one-based indexes, you would
be able to represent one fewer index than zero-based, since one
of the representable values - zero - could no
One reason for zero-based indexes that isn't "it's what we're all
used to" is that if you used one-based indexes, you would be able
to represent one fewer index than zero-based, since one of the
representable values - zero - could no longer be used to
represent any index.
Also, it's what we'r
On Monday, February 06, 2017 17:48:28 Dmitry via Digitalmars-d-learn wrote:
> On Monday, 6 February 2017 at 17:35:02 UTC, Jonathan M Davis
>
> wrote:
> > You have to import std.range to use groupBy.
>
> Of course, "import std.range" already done.
Hmm. Well, the error your getting typically is the
On Monday, 6 February 2017 at 17:35:02 UTC, Jonathan M Davis
wrote:
You have to import std.range to use groupBy.
Of course, "import std.range" already done.
I tested it also with full rosetta's code:
import std.stdio, std.string, std.algorithm, std.array, std.conv,
std.ascii, std.range;
str
On Monday, February 06, 2017 16:43:45 Dmitry via Digitalmars-d-learn wrote:
> Hi. I'm need get list of files in the directory, with natural
> sort, like:
> file_2
> file_8
> file_10
> file_11
> file_20
> file_100
> etc.
>
> Found this https://rosettacode.org/wiki/Natural_sorting#D
> but there is er
On Monday, 6 February 2017 at 14:26:35 UTC, Bastiaan Veelo wrote:
The unit test didn't detect this because it was ambiguous.
Sorry for that misinformation. I should have said that
opIndexAssign wasn't tested. Here is a better test.
unittest {
OneBasedArray!int arr;
arr =
Hi. I'm need get list of files in the directory, with natural
sort, like:
file_2
file_8
file_10
file_11
file_20
file_100
etc.
Found this https://rosettacode.org/wiki/Natural_sorting#D
but there is error on ".groupBy!isDigit" (Error: no property
'groupBy' for type 'string').
with deleted line
On Tuesday, 4 August 2015 at 08:18:50 UTC, Marc Schütz wrote:
void opIndexAssign(U : T)(size_t index, auto ref U
value) {
Careful here, you've got the arguments reversed. The unit test
didn't detect this because it was ambiguous. This one isn't:
unittest {
OneBasedArray!i
19 matches
Mail list logo