Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
On Monday, 5 March 2012 at 15:35:59 UTC, Steven Schveighoffer wrote: On Wed, 29 Feb 2012 20:25:35 -0500, bearophile wrote: Do you know why std.array.Appender defines a "put" method instead of overloading the "~=" operator? It should (in addition to put). I see you have already filed an en

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
I tried to use map! but it's look like it do not work with string, becouse I got error: Error: no property 'map' for type 'ByLine!(char, char)'

Re: Regarding std.array.Appender

2015-10-13 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 13:21:54 UTC, Suliman wrote: I tried to use map! but it's look like it do not work with string, becouse I got error: Error: no property 'map' for type 'ByLine!(char, char)' I suspect you don't have it imported. import std.algorithm; or import std.algorithm : m

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 13:34:02 UTC, John Colvin wrote: On Tuesday, 13 October 2015 at 13:21:54 UTC, Suliman wrote: I tried to use map! but it's look like it do not work with string, becouse I got error: Error: no property 'map' for type 'ByLine!(char, char)' I suspect you don't have

Re: Regarding std.array.Appender

2015-10-13 Thread anonymous via Digitalmars-d-learn
On Tuesday 13 October 2015 15:42, Suliman wrote: > map!(a=> a~=" +") work fine, but how to add before > at same time? Use ~ instead of ~=, like so: map!(a => "+" ~ a ~ "+")

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
something like: auto content = file.byLine.map!("start " ~ a=>a ~ " end");

Re: Regarding std.array.Appender

2015-10-13 Thread anonymous via Digitalmars-d-learn
On Tuesday 13 October 2015 15:47, Suliman wrote: > something like: auto content = file.byLine.map!("start " ~ a=>a ~ > " end"); That's not how it works at all. Maybe stick to the examples of whatever resource you're learning from, for now.

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 13:55:07 UTC, anonymous wrote: On Tuesday 13 October 2015 15:47, Suliman wrote: something like: auto content = file.byLine.map!("start " ~ a=>a ~ " end"); That's not how it works at all. Maybe stick to the examples of whatever resource you're learning from, for

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 13:51:50 UTC, anonymous wrote: On Tuesday 13 October 2015 15:42, Suliman wrote: map!(a=> a~=" +") work fine, but how to add before at same time? Use ~ instead of ~=, like so: map!(a => "+" ~ a ~ "+") Thanks!

dynamic get from variantArray() data table

2015-10-13 Thread data pulverizer via Digitalmars-d-learn
Hi, I am trying to use variantArray() as a data table object to hold columns each of which is an array of a specific type. I need to be able to get values from data table but I am having problems ... import std.stdio; // i/o import std.variant; // type variations void main(){ // Columns o

Re: dynamic get from variantArray() data table

2015-10-13 Thread Alex Parrill via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 15:17:15 UTC, data pulverizer wrote: Hi, I am trying to use variantArray() as a data table object to hold columns each of which is an array of a specific type. I need to be able to get values from data table but I am having problems ... import std.stdio; // i

Re: dynamic get from variantArray() data table

2015-10-13 Thread data pulverizer via Digitalmars-d-learn
Thanks for the suggestion Alex, however I need the dynamic behaviour properties of variantArray(), writing a struct each time would be undesirable. Perhaps I could boil down the question to something like, is there a way of writing auto x = dt[0][0]; auto y = x.get!(x.type - or whatever); //

Re: dynamic get from variantArray() data table

2015-10-13 Thread Alex Parrill via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 16:22:36 UTC, data pulverizer wrote: Thanks for the suggestion Alex, however I need the dynamic behaviour properties of variantArray(), writing a struct each time would be undesirable. Perhaps I could boil down the question to something like, is there a way of w

Re: Hash-Table-Based Multiple Arguments Replacement

2015-10-13 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 11 October 2015 at 11:17:29 UTC, Nordlöw wrote: Here's a solution: https://github.com/nordlow/justd/blob/f8519e8a1af68bc25cc00c6ef12d13efa791250c/comparison_ex.d Latest version contains a few fixes: https://github.com/nordlow/justd/blob/master/comparison_ex.d

Re: Ternary if and ~ does not work quite well

2015-10-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 11, 2015 22:21:55 H. S. Teoh via Digitalmars-d-learn wrote: > It's best to parenthesize when mixing other operators with ?, because ? > has a pretty low precedence and may "steal" arguments from surrounding > operators that you don't intend. My suspicion is that what you wrote i

Struct toString works but not std.conv.to!string

2015-10-13 Thread Nordlöw via Digitalmars-d-learn
I have defined a struct UTCOffset in https://github.com/nordlow/justd/blob/master/datetime_ex.d Everything works as desired except for import std.conv : to; assert(UTCOffset(+14, 0).to!string == "UTC+14:00"); which fails as /usr/include/dmd/phobos/std/conv.d(293,14): Error: template

Re: Struct toString works but not std.conv.to!string

2015-10-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 13, 2015 21:07:07 Nordlöw via Digitalmars-d-learn wrote: > I have defined a struct UTCOffset in > > https://github.com/nordlow/justd/blob/master/datetime_ex.d > > Everything works as desired except for > > import std.conv : to; > assert(UTCOffset(+14, 0).to!string == "

Re: Struct toString works but not std.conv.to!string

2015-10-13 Thread Ali Çehreli via Digitalmars-d-learn
On 10/13/2015 02:07 PM, Nordlöw wrote: I have defined a struct UTCOffset in https://github.com/nordlow/justd/blob/master/datetime_ex.d Everything works as desired except for import std.conv : to; assert(UTCOffset(+14, 0).to!string == "UTC+14:00"); which fails as /usr/include/dmd/ph

Re: Struct toString works but not std.conv.to!string

2015-10-13 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 21:50:54 UTC, Jonathan M Davis wrote: Just glancing at your code, you've marked toString with @property, which is kind of a weird thing to do, nd if we ever make @property enforce that it's not called with parens, then that code won't work. So, you might try movin

Re: Struct toString works but not std.conv.to!string

2015-10-13 Thread anonymous via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 22:21:43 UTC, Ali Çehreli wrote: Reduced with a workaround: struct UTCOffset { import std.conv : to;// Move to module scope to compile This introduces UTCOffset.to as an alias to std.conv.to. string toString() const { return "hello";

OT: why do people use python when it is slow?

2015-10-13 Thread Laeeth Isharc via Digitalmars-d-learn
https://www.quora.com/Why-is-Python-so-popular-despite-being-so-slow Andrei suggested posting more widely.

Re: Class, constructor and inherance.

2015-10-13 Thread Rikki Cattermole via Digitalmars-d-learn
On 13/10/15 5:17 PM, holo wrote: On Tuesday, 13 October 2015 at 02:03:46 UTC, Rikki Cattermole wrote: On 13/10/15 5:56 AM, holo wrote: @Rikki: If you didn't need to make it easily changeable I would say not even bother with OOP at all. Basically that what i had was enough for me and on top

Re: OT: why do people use python when it is slow?

2015-10-13 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 23:26:14 UTC, Laeeth Isharc wrote: https://www.quora.com/Why-is-Python-so-popular-despite-being-so-slow Andrei suggested posting more widely. That's flaimbait: «Many really popular websites use Python. But why is that? Doesn't it affect the performance of the we