Re: What is your favorite D feature?

2017-06-22 Thread k-five via Digitalmars-d
On Thursday, 22 June 2017 at 00:48:25 UTC, Seb wrote: Hi, I am currently trying to modernize the D code example roulette on the dlang.org front page [1]. Hence, I would love to hear about your favorite feature(s) in D. Ideas: - favorite language construct - favorite code sample - "only

[issue std.regex] Fail to match with negative look-ahead assertion when tracking down on a delimiter

2017-05-16 Thread k-five via Digitalmars-d-learn
Although I wanted to post this context at: https://issues.dlang.org/ but even I registered at,I could not login to. -- As long as I know a little about RegExp, the two below patterns are the same: [ 1 ]: ^(?:[ab]|ab)(.)(?:(?!\1).)+\1$ [ 2 ]:

Re: File Input

2017-05-14 Thread k-five via Digitalmars-d-learn
On Sunday, 14 May 2017 at 04:15:02 UTC, JV wrote: Hey i'm not sure if i should create a new post for this but how should i fix this it doesn't pause and store but just keeps reading string studNum; readf("%s",); write(studNum); Can you say exactly what you need? It

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-13 Thread k-five via Digitalmars-d-learn
On Saturday, 13 May 2017 at 10:15:34 UTC, Bastiaan Veelo wrote: On Saturday, 13 May 2017 at 08:23:55 UTC, k-five wrote: [...] OK understood. [...] I am sorry for expressing myself poorly. What I meant to say is that it looked like you can write an interesting article about your

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-13 Thread k-five via Digitalmars-d-learn
On Saturday, 13 May 2017 at 09:05:17 UTC, Jonathan M Davis wrote: For the most part, when parsing a string, std.conv.to's approach of just parsing the string and throwing an exception if/when it fails is the most efficient, because it's only going to parse the string once, whereas calling a

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-13 Thread k-five via Digitalmars-d-learn
On Saturday, 13 May 2017 at 02:40:17 UTC, Mike B Johnson wrote: You are not making a lot of sense: 1. Exception do bubble up, so you don't need to "handle" exceptions at the call site if you don't want to. The whole point of exceptions is do effectively do what you want. 2. You say that

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-13 Thread k-five via Digitalmars-d-learn
On Friday, 12 May 2017 at 20:53:56 UTC, Bastiaan Veelo wrote: Is it safe to say that these 40 lines of D do the same as your 324 lines of C++ [1]? No. I cannot say that. Since this is not a full port of renrem in C++ to D. It was just an example in D, nothing else. This, and your comments

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-12 Thread k-five via Digitalmars-d-learn
On Friday, 12 May 2017 at 11:10:01 UTC, k-five wrote: I was waiting for a stable version of C++17 ( standard library ) to add some features of fileSystem in C++17 to my program that wants to iterate through all files in a directory recursively. I was thinking how could I do for implementing

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-12 Thread k-five via Digitalmars-d-learn
On Friday, 12 May 2017 at 12:56:50 UTC, drug wrote: 12.05.2017 14:58, k-five пишет: On Friday, 12 May 2017 at 11:41:57 UTC, cym13 wrote: On Friday, 12 May 2017 at 11:10:01 UTC, k-five wrote: --- also .each!writeln should be possible

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-12 Thread k-five via Digitalmars-d-learn
On Friday, 12 May 2017 at 11:41:57 UTC, cym13 wrote: On Friday, 12 May 2017 at 11:10:01 UTC, k-five wrote: --- Shorter: void main( string[] args ){ dirEntries( ".", SpanMode.depth, false ) .filter!( file =>

As many thanks As possible to who crates D and UFCS feature

2017-05-12 Thread k-five via Digitalmars-d-learn
I was waiting for a stable version of C++17 ( standard library ) to add some features of fileSystem in C++17 to my program that wants to iterate through all files in a directory recursively. I was thinking how could I do for implementing that and add it to my program. Now after starting to

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-12 Thread k-five via Digitalmars-d-learn
On Friday, 12 May 2017 at 09:03:39 UTC, Jonathan M Davis wrote: That's the wrong isNumeric. Unfortunately, both std.string and std.traits have an isNumeric. std.traits.isNumeric is an eponymous template that tests whether a type is an integral or floating point type, whereas

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-12 Thread k-five via Digitalmars-d-learn
On Friday, 12 May 2017 at 08:32:03 UTC, k-five wrote: On Thursday, 11 May 2017 at 19:59:55 UTC, Jordan Wilson wrote: On Thursday, 11 May 2017 at 18:07:47 UTC, H. S. Teoh wrote: On Thu, May 11, 2017 at 05:55:03PM +, k-five via Digitalmars-d-learn wrote: On Thursday, 11 May 2017 at 17:18:37

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-12 Thread k-five via Digitalmars-d-learn
On Thursday, 11 May 2017 at 19:59:55 UTC, Jordan Wilson wrote: On Thursday, 11 May 2017 at 18:07:47 UTC, H. S. Teoh wrote: On Thu, May 11, 2017 at 05:55:03PM +, k-five via Digitalmars-d-learn wrote: On Thursday, 11 May 2017 at 17:18:37 UTC, crimaniak wrote: > On Wednesday, 10 May 2

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-11 Thread k-five via Digitalmars-d-learn
On Thursday, 11 May 2017 at 17:18:37 UTC, crimaniak wrote: On Wednesday, 10 May 2017 at 12:40:41 UTC, k-five wrote: - try this: https://dlang.org/phobos/std_exception.html#ifThrown Worked. Thanks. import std.stdio; import std.conv:

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-11 Thread k-five via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 21:44:32 UTC, Andrei Alexandrescu wrote: On 5/10/17 3:40 PM, k-five wrote: --- I no need to handle that, so is there any way to prevent this exception? Use the "parse" family: https://dlang.org/phobos/std_conv.html#parse -- Andrei

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-11 Thread k-five via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 21:19:21 UTC, Stanislav Blinov wrote: On Wednesday, 10 May 2017 at 15:35:24 UTC, k-five wrote: On Wednesday, 10 May 2017 at 14:27:46 UTC, Stanislav Blinov --- I don't understand. If you don't want to take

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-10 Thread k-five via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 14:27:46 UTC, Stanislav Blinov wrote: On Wednesday, 10 May 2017 at 13:27:17 UTC, k-five wrote: Thanks, but I know about what are you saying. The user_apply[4] has so many possibilities and I cannot use if-else That doesn't sound right. Either you've already

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-10 Thread k-five via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 13:12:46 UTC, Ivan Kazmenko wrote: On Wednesday, 10 May 2017 at 12:40:41 UTC, k-five wrote: -- I assume that an empty string is a valid input then. The question is, what value do you want `index` to have when

How to avoid throwing an exceptions for a built-in function?

2017-05-10 Thread k-five via Digitalmars-d-learn
I have a line of code that uses "to" function in std.conv for a purpose like: int index = to!int( user_apply[ 4 ] ); // string to int When the user_apply[ 4 ] has value, there is no problem; but when it is empty: "" it throws an ConvException exception and I want to avoid this exception.

Re: Looking for an equivalent to C++ std::getline in D

2017-05-10 Thread k-five via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 10:47:13 UTC, Ali Çehreli wrote: On 05/09/2017 01:17 AM, k-five wrote: > On Monday, 8 May 2017 at 21:37:17 UTC, Ali Çehreli wrote: >> On 05/06/2017 02:24 AM, Stanislav Blinov wrote: >> Plus, wrapping steps of the

Re: Looking for an equivalent to C++ std::getline in D

2017-05-09 Thread k-five via Digitalmars-d-learn
On Monday, 8 May 2017 at 21:37:17 UTC, Ali Çehreli wrote: On 05/06/2017 02:24 AM, Stanislav Blinov wrote: It may D has this philosophy as Perl has: There's more than one way to do it I found more than 5 ways. another way: string[] input = [

Re: File Input

2017-05-08 Thread k-five via Digitalmars-d-learn
On Monday, 8 May 2017 at 10:22:53 UTC, JV wrote: On Monday, 8 May 2017 at 09:26:48 UTC, k-five wrote: On Monday, 8 May 2017 at 08:54:50 UTC, JV wrote: --- If I continue to learn D I will do but there is no guarantee and it got ready :)

Re: File Input

2017-05-08 Thread k-five via Digitalmars-d-learn
On Monday, 8 May 2017 at 08:54:50 UTC, JV wrote: On Sunday, 7 May 2017 at 16:40:50 UTC, k-five wrote: On Sunday, 7 May 2017 at 15:59:25 UTC, JV wrote: --- Do not worry. Your request is not rude. I give you a better tool. I finished to collect

Re: Looking for an equivalent to C++ std::getline in D

2017-05-08 Thread k-five via Digitalmars-d-learn
On Sunday, 7 May 2017 at 20:50:10 UTC, Patrick Schluter wrote: On Sunday, 7 May 2017 at 13:16:16 UTC, bachmeier wrote: On Sunday, 7 May 2017 at 10:33:25 UTC, k-five wrote: --- When I want to learn to code, I asked in some forums about it,

Re: File Input

2017-05-07 Thread k-five via Digitalmars-d-learn
On Sunday, 7 May 2017 at 15:59:25 UTC, JV wrote: On Sunday, 7 May 2017 at 15:16:58 UTC, k-five wrote: On Sunday, 7 May 2017 at 13:57:47 UTC, JV wrote: I'm kinda getting it but how do i write the stored user input(string) varaible into a .txt??im getting confused since D has so many read and

Re: File Input

2017-05-07 Thread k-five via Digitalmars-d-learn
On Sunday, 7 May 2017 at 13:57:47 UTC, JV wrote: Hi guys I'd like to know how to get an input from the user to be stored in a .txt file using import std.file and is it possible to directly write in a .txt file without using a variable to store the user input? Thanks for the answer in

Re: How can I pass an argument to rdmd --evel=

2017-05-07 Thread k-five via Digitalmars-d-learn
On Sunday, 7 May 2017 at 11:11:05 UTC, Vladimir Panteleev wrote: On Sunday, 7 May 2017 at 10:49:25 UTC, k-five wrote: After reading about rdmd and --eval, I tried this: rdmd --eval='auto f=File("ddoc.html");foreach(line;f.byLine) if(line.length<10) writeln(line);f.close' and worked! Now I

How can I pass an argument to rdmd --evel=

2017-05-07 Thread k-five via Digitalmars-d-learn
After reading about rdmd and --eval, I tried this: rdmd --eval='auto f=File("ddoc.html");foreach(line;f.byLine) if(line.length<10) writeln(line);f.close' and worked! Now I am wonder if there is a way to pass "ddoc.html" to this one-liner? that can work with --loop. I mean: // --loop by

Re: Looking for an equivalent to C++ std::getline in D

2017-05-07 Thread k-five via Digitalmars-d-learn
On Sunday, 7 May 2017 at 09:46:22 UTC, Patrick Schluter wrote: On Saturday, 6 May 2017 at 10:15:03 UTC, k-five wrote: If you want to learn the basis of the range concept and their link to C++ Iterators, you should definitively read Andrei's article on them in the InformIT magazine. Here is

Re: Looking for an equivalent to C++ std::getline in D

2017-05-06 Thread k-five via Digitalmars-d-learn
On Saturday, 6 May 2017 at 10:35:05 UTC, Stanislav Blinov wrote: On Saturday, 6 May 2017 at 10:15:03 UTC, k-five wrote: On Saturday, 6 May 2017 at 08:53:12 UTC, Jonathan M Davis wrote: On Saturday, May 6, 2017 8:34:11 AM CEST k-five via Digitalmars-d-learn wrote: On Friday, 5 May 2017 at 17:07

Re: Looking for an equivalent to C++ std::getline in D

2017-05-06 Thread k-five via Digitalmars-d-learn
On Saturday, 6 May 2017 at 08:53:12 UTC, Jonathan M Davis wrote: On Saturday, May 6, 2017 8:34:11 AM CEST k-five via Digitalmars-d-learn wrote: On Friday, 5 May 2017 at 17:07:25 UTC, Stanislav Blinov wrote: > On Friday, 5 May 2017 at 09:54:03 UTC, k-five wr

Re: Looking for an equivalent to C++ std::getline in D

2017-05-06 Thread k-five via Digitalmars-d-learn
On Friday, 5 May 2017 at 17:07:25 UTC, Stanislav Blinov wrote: On Friday, 5 May 2017 at 09:54:03 UTC, k-five wrote: == Thanks. I only needed this part since it filters the empty elements and this is enough for me: auto input =

Looking for an equivalent to C++ std::getline in D

2017-05-05 Thread k-five via Digitalmars-d-learn
Hi all. I have a simple command-line program utility in C++ that can rename or remove files, based on regular expression. After finding D that is more fun than C++ is, I want to port the code, but I have problem with this part of it: std::getline( iss, match, delimiter );