string to uppercase

2016-04-02 Thread stunaep via Digitalmars-d-learn
Is there any easy way to convert a string to uppercase? I tried s.asUpperCase, but it returns a ToCaserImpl, not a string, and it cant be cast to string. I also tried toUpper but it wasnt working with strings

Re: string to uppercase

2016-04-02 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 3 April 2016 at 03:05:08 UTC, stunaep wrote: Is there any easy way to convert a string to uppercase? I tried s.asUpperCase, but it returns a ToCaserImpl, not a string, and it cant be cast to string. I also tried toUpper but it wasnt working with strings asUpperCase returns a range

Decompressing bzip2

2016-04-02 Thread stunaep via Digitalmars-d-learn
I am trying to use the bzip2 bindings that are available on code.dlang.org/packages, but I am having a really hard time using it due to the pointers. It needs to be an array once it's decompressed. Here is what I have: import std.stdio; import bzlib; void main(string[] args) { File f =

Idiomatic way to generate all possible values a static array of ubyte can have

2016-04-02 Thread jkpl via Digitalmars-d-learn
Let's say I have a ubyte[256]. I want to test all the possible values this array can have on a function. Currently I fill it for each new test with std.random.uniform but I'm sure that I loose some time with randomizing and with the tests that are repeated. Is there a simple way to do this ?

Re: Idiomatic way to generate all possible values a static array of ubyte can have

2016-04-02 Thread jkpl via Digitalmars-d-learn
On Saturday, 2 April 2016 at 08:27:07 UTC, rikki cattermole wrote: On 02/04/2016 9:20 PM, jkpl wrote: Let's say I have a ubyte[256]. I want to test all the possible values this array can have on a function. Actually I'd use a hex string. So: static ubyte[256] DATA = cast(ubyte[256])x"00 01

Re: Idiomatic way to generate all possible values a static array of ubyte can have

2016-04-02 Thread jkpl via Digitalmars-d-learn
On Saturday, 2 April 2016 at 09:11:34 UTC, jkpl wrote: On Saturday, 2 April 2016 at 08:48:10 UTC, rikki cattermole wrote: On 02/04/2016 9:36 PM, jkpl wrote: On Saturday, 2 April 2016 at 08:27:07 UTC, rikki cattermole wrote: Okay that is a problem then. Yes clearly! Maybe this, a bit

Re: Idiomatic way to generate all possible values a static array of ubyte can have

2016-04-02 Thread jkpl via Digitalmars-d-learn
gives: core.exception.OutOfMemoryError@src/core/exception.d(693): Memory allocation failed

Re: Idiomatic way to generate all possible values a static array of ubyte can have

2016-04-02 Thread rikki cattermole via Digitalmars-d-learn
On 02/04/2016 9:36 PM, jkpl wrote: On Saturday, 2 April 2016 at 08:27:07 UTC, rikki cattermole wrote: On 02/04/2016 9:20 PM, jkpl wrote: Let's say I have a ubyte[256]. I want to test all the possible values this array can have on a function. Actually I'd use a hex string. So: static

Re: Idiomatic way to generate all possible values a static array of ubyte can have

2016-04-02 Thread jkpl via Digitalmars-d-learn
On Saturday, 2 April 2016 at 08:48:10 UTC, rikki cattermole wrote: On 02/04/2016 9:36 PM, jkpl wrote: On Saturday, 2 April 2016 at 08:27:07 UTC, rikki cattermole wrote: Okay that is a problem then. Yes clearly! Maybe this, a bit better: foreach (b0; randomCover(iota(0,256)))

Re: pass a struct by value/ref and size of the struct

2016-04-02 Thread ZombineDev via Digitalmars-d-learn
On Saturday, 2 April 2016 at 09:28:58 UTC, ZombineDev wrote: On Wednesday, 23 March 2016 at 19:39:49 UTC, kinke wrote: On Tuesday, 22 March 2016 at 07:35:49 UTC, ZombineDev wrote: If the object is larger than the size of a register on the target machine, it is implicitly passed by ref That's

Re: Direntries seems to on other drives. (windows)

2016-04-02 Thread Vladimir Panteleev via Digitalmars-d-learn
On Friday, 1 April 2016 at 02:05:23 UTC, Taylor Hillegeist wrote: Even though i just checked for a valid path. [...] if(!args[1].buildNormalizedPath.isValidPath){writeln("Path is invalid! "); return;} From https://dlang.org/library/std/path/is_valid_path.html : It does *not* check

Re: Idiomatic way to generate all possible values a static array of ubyte can have

2016-04-02 Thread rikki cattermole via Digitalmars-d-learn
On 02/04/2016 9:20 PM, jkpl wrote: Let's say I have a ubyte[256]. I want to test all the possible values this array can have on a function. Currently I fill it for each new test with std.random.uniform but I'm sure that I loose some time with randomizing and with the tests that are repeated. Is

Re: pass a struct by value/ref and size of the struct

2016-04-02 Thread ZombineDev via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 19:39:49 UTC, kinke wrote: On Tuesday, 22 March 2016 at 07:35:49 UTC, ZombineDev wrote: If the object is larger than the size of a register on the target machine, it is implicitly passed by ref That's incorrect. As Johan pointed out, this is somewhat true for

Address of an element of AA

2016-04-02 Thread Temtaime via Digitalmars-d-learn
Hi ! I can't find this in specs. If i add an element to AA: aa[10] = 123; Will [10] be always the same (of course i don't remove that key) ? Thanks for a reply. I think specs should be enhanced.

Re: Idiomatic way to generate all possible values a static array of ubyte can have

2016-04-02 Thread Ali Çehreli via Digitalmars-d-learn
[Probably a repost.] On 04/02/2016 01:20 AM, jkpl wrote: Let's say I have a ubyte[256]. I want to test all the possible values this array can have on a function. nextPermutation(): https://dlang.org/phobos/std_algorithm_sorting.html#nextPermutation Ali

Re: No aa.byKey.length?

2016-04-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, April 02, 2016 15:38:30 Ozan via Digitalmars-d-learn wrote: > On Friday, 1 April 2016 at 20:50:32 UTC, Yuxuan Shui wrote: > > Why? > > > > This is annoying when I need to feed it into a function that > > requires hasLength. > > aa.keys.length That allocates an array. Doing that would

Re: Address of an element of AA

2016-04-02 Thread Ali Çehreli via Digitalmars-d-learn
On 04/02/2016 07:22 AM, Temtaime wrote: Hi ! I can't find this in specs. If i add an element to AA: aa[10] = 123; Will [10] be always the same (of course i don't remove that key) ? Thanks for a reply. I think specs should be enhanced. No, the underlying buffer can be relocated when the hash

Re: Address of an element of AA

2016-04-02 Thread Ozan via Digitalmars-d-learn
On Saturday, 2 April 2016 at 14:22:01 UTC, Temtaime wrote: Hi ! I can't find this in specs. If i add an element to AA: aa[10] = 123; Will [10] be always the same (of course i don't remove that key) ? Thanks for a reply. I think specs should be enhanced. Running following int

Re: No aa.byKey.length?

2016-04-02 Thread Ozan via Digitalmars-d-learn
On Friday, 1 April 2016 at 20:50:32 UTC, Yuxuan Shui wrote: Why? This is annoying when I need to feed it into a function that requires hasLength. aa.keys.length

Re: Idiomatic way to generate all possible values a static array of ubyte can have

2016-04-02 Thread jkpl via Digitalmars-d-learn
On Saturday, 2 April 2016 at 18:32:03 UTC, Steven Schveighoffer wrote: I honestly think you are better off just generating random arrays, even if it results in some overlap (unlikely to be relevant). -Steve Yes I know, I've realized how it's silly. just foreach(xn; 0 .. range) foreach(xn;

Re: Idiomatic way to generate all possible values a static array of ubyte can have

2016-04-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/2/16 5:47 AM, jkpl wrote: gives: core.exception.OutOfMemoryError@src/core/exception.d(693): Memory allocation failed Probably because randomCover needs to allocate a bool for all the elements it has already covered, so you are allocating 32 * 4G bools. How much RAM do you have? Note

Re: Address of an element of AA

2016-04-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/2/16 10:22 AM, Temtaime wrote: Hi ! I can't find this in specs. If i add an element to AA: aa[10] = 123; Will [10] be always the same (of course i don't remove that key) ? Thanks for a reply. I think specs should be enhanced. Depends on your definition of "always". As long as you don't