Hello,
This bit of code for arrays:
Out[] map (In,Out) (In[] input, Out delegate (In) f) {
Out[] output = new Out[](input.length);
foreach (i,item ; input)
output [i] = f(item);
return output;
}
unittest {
char character (uint code) {return cast(char)code;}
uint[] cod
On Wed, 02 Feb 2011 13:26:39 +0100, spir wrote:
> Hello,
>
> This bit of code for arrays:
>
> Out[] map (In,Out) (In[] input, Out delegate (In) f) {
> Out[] output = new Out[](input.length); foreach (i,item ; input)
> output [i] = f(item);
> return output;
> }
> unittest {
>
On Wed, 02 Feb 2011 13:18:07 +, Lars T. Kyllingstad wrote:
> [...]
>
> struct Map(Range, In, Out)
> if (isInputRange!Range && is(ElementType!Range : In)
> {
> Range input;
> Out delegate(In) f;
>
> @property bool empty() { return input.empty; }
>
> // Ineff
On 02/02/2011 02:18 PM, Lars T. Kyllingstad wrote:
On Wed, 02 Feb 2011 13:26:39 +0100, spir wrote:
Hello,
This bit of code for arrays:
Out[] map (In,Out) (In[] input, Out delegate (In) f) {
Out[] output = new Out[](input.length); foreach (i,item ; input)
output [i] = f(item);
On Wed, 02 Feb 2011 18:38:02 +0100, spir wrote:
> On 02/02/2011 02:18 PM, Lars T. Kyllingstad wrote:
>> On Wed, 02 Feb 2011 13:26:39 +0100, spir wrote:
>>
>>> Hello,
>>>
>>> This bit of code for arrays:
>>>
>>> Out[] map (In,Out) (In[] input, Out delegate (In) f) {
>>> Out[] output = new Out
On 02/03/2011 08:41 AM, Lars T. Kyllingstad wrote:
On Wed, 02 Feb 2011 18:38:02 +0100, spir wrote:
I guess the only solution would be for the compiler to support a kind of
reange type syntax?
I'm not sure I understand what you mean here. Perhaps you're looking for
something like concepts, w
On Thu, 03 Feb 2011 13:05:00 +0100, spir wrote:
> On 02/03/2011 08:41 AM, Lars T. Kyllingstad wrote:
>> On Wed, 02 Feb 2011 18:38:02 +0100, spir wrote:
>
>>> I guess the only solution would be for the compiler to support a kind
>>> of reange type syntax?
>>
>> I'm not sure I understand what you m
On 02/03/2011 01:17 PM, Lars T. Kyllingstad wrote:
Why the reluctance to use template constraints? They're so flexible! :)
I cannot stand the "is()" idiom/syntax ;-) Dunno why. Would happily get rid of
it in favor of type-classes (built eg as an extension to current interfaces).
For instance
On Thu, 03 Feb 2011 13:53:44 +0100, spir wrote:
> On 02/03/2011 01:17 PM, Lars T. Kyllingstad wrote:
>> Why the reluctance to use template constraints? They're so flexible!
>> :)
>
> I cannot stand the "is()" idiom/syntax ;-) Dunno why. Would happily get
> rid of it in favor of type-classes (bui
On 02/03/2011 02:25 PM, Lars T. Kyllingstad wrote:
On Thu, 03 Feb 2011 13:53:44 +0100, spir wrote:
On 02/03/2011 01:17 PM, Lars T. Kyllingstad wrote:
Why the reluctance to use template constraints? They're so flexible!
:)
I cannot stand the "is()" idiom/syntax ;-) Dunno why. Would happily g
On Thu, 03 Feb 2011 19:11:04 +0100, spir wrote:
> On 02/03/2011 02:25 PM, Lars T. Kyllingstad wrote:
>> On Thu, 03 Feb 2011 13:53:44 +0100, spir wrote:
>>
>>> On 02/03/2011 01:17 PM, Lars T. Kyllingstad wrote:
Why the reluctance to use template constraints? They're so flexible!
:)
>>>
>
On 02/07/2011 09:18 AM, Lars T. Kyllingstad wrote:
I cannot stand the "is()" idiom/syntax ;-) Dunno why. Would happily
>>> get rid of it in favor of type-classes (built eg as an extension to
>>> current interfaces). For instance, instead of:
>>>
>>> void func (T) (T t)
>>> i
If you want to use an interface as a concept, you can take kenji's
adaptTo module and add this:
template conformsTo(T, Interfaces...)
{
enum conformsTo = AdaptTo!Interfaces.hasRequiredMethods!T;
}
and use it like this
void draw(T)(T shape) if (conformsTo!(T, Shape, Drawable))
This will of cour
On 02/07/2011 01:07 PM, Torarin wrote:
If you want to use an interface as a concept, you can take kenji's
adaptTo module and add this:
template conformsTo(T, Interfaces...)
{
enum conformsTo = AdaptTo!Interfaces.hasRequiredMethods!T;
}
and use it like this
void draw(T)(T shape) if (conformsT
14 matches
Mail list logo