Reducing an array

2014-04-18 Thread Tim Holzschuh via Digitalmars-d-learn
Hi there, I try to remove all equal elements of an array, thus [2,2] -- [2]. I thought this maybe would be possible with std.algorithm.reduce, but at least the way I tried it doesn't work: arr.reduce( (a,b) = a != b ); Is there a simple solution using Phobos-functions? Thank you, Tim

Re: *** GMX Spamverdacht *** Re: Reducing an array

2014-04-19 Thread Tim Holzschuh via Digitalmars-d-learn
Am 18.04.2014 22:27, schrieb Steven Schveighoffer via Digitalmars-d-learn: arr.sort(); arr = arr.uniq.array(); -Steve Thanks, also for the explanation! - Tim

Named template constraints

2014-04-22 Thread Tim Holzschuh via Digitalmars-d-learn
Hi there, I recently read the 'More Templates' chapter of Ali's book (-- thanks for that ;) ). At the section 'Named constraints', there were a definition like this: template isUsable(T) { enum isUsable = is ( typeof( { T obj; obj.call(); obj.otherCall(1);

Re: Named template constraints

2014-04-22 Thread Tim Holzschuh via Digitalmars-d-learn
Am 22.04.2014 16:58, schrieb Andrej Mitrovic via Digitalmars-d-learn: On 4/22/14, Tim Holzschuh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: What does (inout int = 0) mean/affect here? This was asked recently, see my reponse here: http://forum.dlang.org/post/mailman

Math-Parser

2014-05-02 Thread Tim Holzschuh via Digitalmars-d-learn
Hi there, I currently try to write a simple math-parser in D. However.. something isn't working and I just can't figure out what's the problem. (I'm relative new to D, and this is my first test to write a parser/lexer) I'm pretty sure it's a simple layer-8-problem, but I always overlook it.

Re: *** GMX Spamverdacht *** Re: Math-Parser

2014-05-03 Thread Tim Holzschuh via Digitalmars-d-learn
Am 03.05.2014 11:17, schrieb Rikki Cattermole via Digitalmars-d-learn: General suggestions: Don't commit the build ext. files along with source code and in this case they aren't needed. Mono-D can load dub.json straight. As well as the obj/bin directories. Yeah you're right, thank you. (And

Re: Math-Parser

2014-05-03 Thread Tim Holzschuh via Digitalmars-d-learn
Am 03.05.2014 13:29, schrieb Timon Gehr via Digitalmars-d-learn: @property Lexer lexer() pure { return _lexer; } If you change the result of a call to 'lexer' this will not change '_lexer'. Mark the property 'ref' or get rid of it How did I forget about Lexer being a struct is a value

Re: Math-Parser

2014-05-04 Thread Tim Holzschuh via Digitalmars-d-learn
Am 03.05.2014 21:47, schrieb Timon Gehr via Digitalmars-d-learn: On 05/03/2014 08:20 PM, Tim Holzschuh via Digitalmars-d-learn wrote: Let me know if you also want hints on how to get the logic right. Would be very nice! While 2*2 works, 2+2 throws an Error because the number-method gets

RegEx for a simple Lexer

2014-05-13 Thread Tim Holzschuh via Digitalmars-d-learn
Hi there, I read a book about an introduction to creating programming languages (really basic). The sample code is written in Ruby, but I want to rewrite the examples in D. However, the Lexer uses Ruby's regex features to scan the code. I'm not very familiar with D's RegEx system (nor with

Re: *** GMX Spamverdacht *** RegEx for a simple Lexer

2014-05-13 Thread Tim Holzschuh via Digitalmars-d-learn
Am 13.05.2014 21:53, schrieb Tim Holzschuh via Digitalmars-d-learn: In the book a parser generator like Yacc is used to create a suitable parser. Is there an equivalent for D? Or if not: is it really that hard to create a parser that is able to parse sth. like this: Ah, found pegged [1

Re: *** GMX Spamverdacht *** RegEx for a simple Lexer

2014-05-15 Thread Tim Holzschuh via Digitalmars-d-learn
Am 13.05.2014 21:53, schrieb Tim Holzschuh via Digitalmars-d-learn: [...] Thank you for all your interesing links and tips, I'll check these out! Tim