Re: Splitting a range into a range of tuples

2015-06-01 Thread Adam via Digitalmars-d-learn
Everything is fine until I try to instantiate Tuples with my arrays. Then I get an error that says none of the overloads of the constructor are callable with these arguments. But I see this: http://dlang.org/phobos/std_typecons.html#.Tuple.this.2 , which makes me think it should work. Am I do

Re: convert base

2015-06-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/1/15 8:36 PM, Hugo wrote: On Tuesday, 2 June 2015 at 00:00:43 UTC, Steven Schveighoffer wrote: On 6/1/15 7:16 PM, Hugo wrote: Thanks! Is there a way to specify a source base different than 10? A "source base"? the source base is always binary :) If you want to go between base string rep

Re: convert base

2015-06-01 Thread Hugo via Digitalmars-d-learn
On Tuesday, 2 June 2015 at 00:00:43 UTC, Steven Schveighoffer wrote: On 6/1/15 7:16 PM, Hugo wrote: Thanks! Is there a way to specify a source base different than 10? A "source base"? the source base is always binary :) If you want to go between base string representation, there is parse for

Re: Splitting a range into a range of tuples

2015-06-01 Thread Adam via Digitalmars-d-learn
auto result = input .splitter(',') .map!splitter .joiner .map!(to!int) .chunks(2) .map!array .array .sort() .retro; Thanks for th

Re: convert base

2015-06-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/1/15 7:16 PM, Hugo wrote: On Monday, 1 June 2015 at 19:53:50 UTC, Steven Schveighoffer wrote: On 6/1/15 3:43 PM, Hugo wrote: How could I convert a number form binary to an arbitrary base like 19 or 23? import std.conv; to!(string)(100, 19); // "55" Thanks! Is there a way to specify a

Re: Splitting a range into a range of tuples

2015-06-01 Thread Dennis Ritchie via Digitalmars-d-learn
On Monday, 1 June 2015 at 22:31:38 UTC, Adam wrote: Hi, I have a string of pairs of integers, where pairs are delimited from each other by commas, and members of the pair are delimited by a space. I'd like to end up with something like a range of 2-tuples I can offer this option: import st

Re: Splitting a range into a range of tuples

2015-06-01 Thread Ali Çehreli via Digitalmars-d-learn
On 06/01/2015 03:31 PM, Adam wrote: Hi, I have a string of pairs of integers, where pairs are delimited from each other by commas, and members of the pair are delimited by a space. I'd like to end up with something like a range of 2-tuples, which I can then sort with a lambda. I'm running into p

Re: convert base

2015-06-01 Thread Hugo via Digitalmars-d-learn
On Monday, 1 June 2015 at 19:53:50 UTC, Steven Schveighoffer wrote: On 6/1/15 3:43 PM, Hugo wrote: How could I convert a number form binary to an arbitrary base like 19 or 23? import std.conv; to!(string)(100, 19); // "55" Thanks! Is there a way to specify a source base different than 10?

Re: attribute alias? eg: asm @my_alias {...} alias my_alias=pure nothrow @trusted @nogc;

2015-06-01 Thread Mike via Digitalmars-d-learn
On Sunday, 31 May 2015 at 04:02:19 UTC, Timothee Cour wrote: Is there a way to alias attributes? alias my_alias=pure nothrow @trusted @nogc; asm @my_alias {...} I'm not sure if this will work for you, but check out the last part of this post: http://forum.dlang.org/post/sfwtxngbiamlketod...@

Splitting a range into a range of tuples

2015-06-01 Thread Adam via Digitalmars-d-learn
Hi, I have a string of pairs of integers, where pairs are delimited from each other by commas, and members of the pair are delimited by a space. I'd like to end up with something like a range of 2-tuples, which I can then sort with a lambda. I'm running into problems trying to do this, after

Re: convert base

2015-06-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/1/15 3:43 PM, Hugo wrote: How could I convert a number form binary to an arbitrary base like 19 or 23? import std.conv; to!(string)(100, 19); // "55" -Steve

convert base

2015-06-01 Thread Hugo via Digitalmars-d-learn
How could I convert a number form binary to an arbitrary base like 19 or 23?

Re: return string from inside if block => Segmentation Fault: 11

2015-06-01 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-06-01 16:54:58 +, Alex Parrill said: Are you sure that it's not the calls to `isEmpty`? Check if spec, lvars, or anything that `isEmpty` uses are null. Yep, I was confused by my own naming. I don't have to check against isEmpty but instead "... is null" ... -- Robert M. Münch ht

Re: return string from inside if block => Segmentation Fault: 11

2015-06-01 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 1 June 2015 at 17:19:50 UTC, Robert M. Münch wrote: Isn't the construtor of the contained types run when the class is constructed? Or do I need to explicitly initialize the contained types on my own? (haven't touched the OO part of D yet so much) Classes are not automatically cr

Re: return string from inside if block => Segmentation Fault: 11

2015-06-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/1/15 1:19 PM, Robert M. Münch wrote: On 2015-06-01 17:06:27 +, Kapps said: Chances are very good that it's the code within the if statement, classes are null by default, you're checking if null isEmpty, thus getting a segfault. Isn't the construtor of the contained types run when the

Re: return string from inside if block => Segmentation Fault: 11

2015-06-01 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-06-01 17:06:27 +, Kapps said: Chances are very good that it's the code within the if statement, classes are null by default, you're checking if null isEmpty, thus getting a segfault. Isn't the construtor of the contained types run when the class is constructed? Or do I need to ex

Re: return string from inside if block => Segmentation Fault: 11

2015-06-01 Thread Kapps via Digitalmars-d-learn
On Monday, 1 June 2015 at 16:52:30 UTC, Robert M. Münch wrote: I'm a bit confused... I have the following class: class foo : superFoo { aFoo spec; aFoo lvars; aFoo bdy; override string toString(){ if(spec.isEmpty() && lvars.isEmpty()){ return "does spec"; } if(lvars.isEmpty()){

Re: return string from inside if block => Segmentation Fault: 11

2015-06-01 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 1 June 2015 at 16:52:30 UTC, Robert M. Münch wrote: I'm a bit confused... I have the following class: class foo : superFoo { aFoo spec; aFoo lvars; aFoo bdy; override string toString(){ if(spec.isEmpty() && lvars.isEmpty()){ return "does spec"; } if(lvars.isEmpty()){

return string from inside if block => Segmentation Fault: 11

2015-06-01 Thread Robert M. Münch via Digitalmars-d-learn
I'm a bit confused... I have the following class: class foo : superFoo { aFoo spec; aFoo lvars; aFoo bdy; override string toString(){ if(spec.isEmpty() && lvars.isEmpty()){ return "does spec"; } if(lvars.isEmpty()){ return "funct spec"; } return "function spec"; } }