Re: using parse with string slice

2015-12-05 Thread Quentin Ladeveze via Digitalmars-d-learn
On Saturday, 5 December 2015 at 22:05:11 UTC, anonymous wrote: On 05.12.2015 22:59, Quentin Ladeveze wrote: --- import std.conv; string s = "1B2A"; int value = parse!int(s[0..2], 16); //template std.conv.parse cannot deduce function from argument types !(int)(string, int) --- Does someone h

using parse with string slice

2015-12-05 Thread Quentin Ladeveze via Digitalmars-d-learn
Hi, I try to parse some hexadecimal numbers stocked in a string. So I use this code --- import std.conv; string s = "B"; int value = parse!int(s, 16); assert(value == 11); --- But when I have several hexadecimal numbers in the string, and I slice it, the compiler can't deduce which versi

Re: Retrieving call expression of a function

2015-11-28 Thread Quentin Ladeveze via Digitalmars-d-learn
On Saturday, 28 November 2015 at 17:19:40 UTC, tcak wrote: On Saturday, 28 November 2015 at 15:41:59 UTC, Quentin Ladeveze wrote: [...] mixin template could solve this problem as well I guess. It would, instead of calling a function, directly inject the code into where you call it. So, remov

Re: Retrieving call expression of a function

2015-11-28 Thread Quentin Ladeveze via Digitalmars-d-learn
On Saturday, 28 November 2015 at 15:22:51 UTC, tcak wrote: On Saturday, 28 November 2015 at 15:02:32 UTC, Quentin Ladeveze wrote: Hi, Is it possible to retrieve the calling expression of a function ? Something like that --- import std.stdio; void funcTest(int x, float y) { writefln(get_ca

Retrieving call expression of a function

2015-11-28 Thread Quentin Ladeveze via Digitalmars-d-learn
Hi, Is it possible to retrieve the calling expression of a function ? Something like that --- import std.stdio; void funcTest(int x, float y) { writefln(get_call()); } void main() { float x = 0.2; funcTest(1+2, x+2); } --- output expected : " funcTest(1+2, x+2) " Thanks

Re: Communicating with external processes in D

2015-11-23 Thread Quentin Ladeveze via Digitalmars-d-learn
On Monday, 23 November 2015 at 20:02:16 UTC, Cameron Reid wrote: I'm rather new to D, so apologies if this is a silly question: I'd like to be able to fork a number of instances of a process, write to their stdins and read from their stdouts in parallel. That is, I want to write some data to t

Re: Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn
On Friday, 19 June 2015 at 15:47:09 UTC, ZombineDev wrote: On Friday, 19 June 2015 at 14:13:46 UTC, Quentin Ladeveze wrote: [..] These are interesting and can be useful, but allMembers returns strings and not functions, so I can't apply ReturnType. Here's my solution: http://dpaste.dzfl.pl/c6

Re: Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn
On Friday, 19 June 2015 at 15:36:54 UTC, Justin Whear wrote: On Fri, 19 Jun 2015 13:27:13 +, Quentin Ladeveze wrote: Is there any way to have a asTuple method in this struct that would returns something like : Tuple!(int, "a", float, "b", string, "c") and that will contain the values of

Re: Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn
On Friday, 19 June 2015 at 14:42:59 UTC, Steven Schveighoffer wrote: On 6/19/15 10:13 AM, Quentin Ladeveze wrote: On Friday, 19 June 2015 at 14:04:05 UTC, Daniel Kozák wrote: On Fri, 19 Jun 2015 13:52:52 + Quentin Ladeveze via Digitalmars-d-learn wrote: On Friday, 19 June 2015 at 13:38

Re: Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn
On Friday, 19 June 2015 at 14:04:05 UTC, Daniel Kozák wrote: On Fri, 19 Jun 2015 13:52:52 + Quentin Ladeveze via Digitalmars-d-learn wrote: On Friday, 19 June 2015 at 13:38:45 UTC, Steven Schveighoffer wrote: > > Does this work for you, or is there a further expectation? &g

Re: Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn
On Friday, 19 June 2015 at 13:38:45 UTC, Steven Schveighoffer wrote: Does this work for you, or is there a further expectation? auto asTuple() { return Tuple!(int, "a", ...)(a, b, stringValue);} -Steve In fact, I was trying to use traits to create the tuple automatically and being able to

Re: Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn
On Friday, 19 June 2015 at 13:26:03 UTC, Steven Schveighoffer wrote: On 6/19/15 9:13 AM, Quentin Ladeveze wrote: On Friday, 19 June 2015 at 13:12:08 UTC, Quentin Ladeveze wrote: Hi, I have a struct with some methods int it, let's say ``` struct Example{ int intValue(){ Hum. How can I d

Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn
Hi, I have a struct with some methods int it, let's say ``` struct Example{ int intValue(){

Re: Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn
On Friday, 19 June 2015 at 13:12:08 UTC, Quentin Ladeveze wrote: Hi, I have a struct with some methods int it, let's say ``` struct Example{ int intValue(){ Hum. How can I delete a post ?

Re: appender!(dchar[]) put fail

2015-06-13 Thread Quentin Ladeveze via Digitalmars-d-learn
On Saturday, 13 June 2015 at 13:32:19 UTC, kerdemdemir wrote: Thanks lot that is really good. One more question I am asking those kind of questions to understand and not ask same stuff over and over, : Don't worry, there is "learn" in "D.learn" auto totalStr = chain(stringB.replicate(bCou

Re: appender!(dchar[]) put fail

2015-06-13 Thread Quentin Ladeveze via Digitalmars-d-learn
On Saturday, 13 June 2015 at 12:02:10 UTC, kerdemdemir wrote: The problem is that your appender is a char appender, and you try to put a dstring into it. Replace : charAppender.put(totalStr); by : foreach(elem; totalStr){ charAppender.put(elem); } elem will be a dchar, so it will work.

Re: appender!(dchar[]) put fail

2015-06-13 Thread Quentin Ladeveze via Digitalmars-d-learn
On Saturday, 13 June 2015 at 10:45:58 UTC, kerdemdemir wrote: I have two strings(stringB,stringC) which I need to repeat(bCount times, cCountTimes) and then chain. auto charAppender = appender!(dchar[]); auto totalStr = stringB.repeat(bCount).chain(stringC.repeat(cCount)); This compiles and