Re: construct range from tuple?

2016-09-18 Thread Lutger via Digitalmars-d-learn
On Sunday, 18 September 2016 at 09:36:13 UTC, e-y-e wrote: On Sunday, 18 September 2016 at 08:06:54 UTC, Lutger wrote: [...] Use std.range's 'only' function [1], it takes variadic arguments of the same type and constructs a range consisting of them. Example: import std.meta :

Re: Can vibe d leverage existing web technologies?

2016-09-18 Thread Lutger via Digitalmars-d-learn
On Thursday, 15 September 2016 at 20:56:19 UTC, Intersteller wrote: On Thursday, 15 September 2016 at 14:31:28 UTC, Martin Tschierschke wrote: On Tuesday, 13 September 2016 at 23:45:18 UTC, Intersteller wrote: vibe.d does not have much lateral support as the most commons web technologies do.

construct range from tuple?

2016-09-18 Thread Lutger via Digitalmars-d-learn
I have a tuple of strings generated at compile time, for example: alias names = AliasSeq!("Alice", "Bob"); How is it possible to construct a range of strings from this, in order to use it at runtime with other range algorithms? For example, this chain(names, ["Chuck"]) doesn't work as

Equivalent of FirstOrDefault with ranges

2016-09-02 Thread Lutger via Digitalmars-d-learn
I was looking for something like FirstOrDefault* from .NET in phobos. For example, I have this piece of code: string findBobOrReturnNull(string[] names) { auto r = names.find("bob"); if(r.empty) return null; return r.front; } assert(findBobOrReturnNull(["alice", "bob"]) == "bob");