Comment #0 by khurshid.normuradov — 2013-04-21T22:25:01Z
Created attachment 1210
test staticMap algorithm
More compile time algorithms (as, staticIndexOf, staticMap, EraseAll,
NoDuplicates, etc) - implemented as recursion. But this implementation need
deep recursion. So I had test staticMap with more 500 arguments. It's not
compiled with normal configuration of dmd . After that I rewrite own staticMap2
with little change:
template staticMap2(alias F, T...)
{
static if (T.length == 0)
{
alias TypeTuple!() staticMap2;
} else static if (T.length == 1)
{
alias TypeTuple!(F!(T[0])) staticMap2;
} else {
alias TypeTuple!( staticMap2!(F, T[0..$/2]), staticMap2!(F,T[$/2..$]))
staticMap2 ;
}
And this variant compiled more than 32768 arguments.
For small arguments both version compiled almost the same time.
Which opinion is on this matter?
-------------------------------
test program is attachment.
---------------------------------
I hope you didn't work on a pull request as well; Kenji was fast(er), as usual.
If you have additional suggestions, feel free to reopen the issue or post a new one.
Comment #4 by khurshid.normuradov — 2013-04-23T00:27:06Z
(In reply to comment #3)
> I hope you didn't work on a pull request as well; Kenji was fast(er), as usual.
>
> If you have additional suggestions, feel free to reopen the issue or post a new
> one.
Yes, I am first time here.
Comment #5 by khurshid.normuradov — 2013-04-23T00:36:32Z
And this :))
template Reverse(TList...)
{
static if (TList.length <= 1 )
alias TList Reverse;
else
alias TypeTuple!( TList[$-1], Reverse!(TList[1..$-1]), TList[0]) Reverse;
}
:)))
Comment #6 by khurshid.normuradov — 2013-04-23T01:05:52Z
(In reply to comment #5)
> And this :))
>
> template Reverse(TList...)
> {
> static if (TList.length <= 1 )
> alias TList Reverse;
> else
> alias TypeTuple!( TList[$-1], Reverse!(TList[1..$-1]), TList[0])
> Reverse;
>
> }
>
> :)))
or
template Reverse (TList...)
{
static if (TList.length <= 1 )
{
alias Reverse = TList;
} else {
alias Reverse = TypeTuple!( Reverse !(TList[$/2..$]) , Reverse!(TList[0..$/2]));
}
}
Comment #11 by andrej.mitrovich — 2013-05-31T18:57:43Z
(In reply to comment #9)
> I'm not sure, but, is this right?
>
> template MostDerived(T, TList...)
Is this the last one left? Someone should make a pull for it.
Comment #12 by khurshid.normuradov — 2013-06-14T06:30:59Z
(In reply to comment #11)
> (In reply to comment #9)
> > I'm not sure, but, is this right?
> >
> > template MostDerived(T, TList...)
>
> Is this the last one left? Someone should make a pull for it.
Not only this, I think that all following algorithms can easily change, too:
1. DerivedToFront
2. MostDerived
3. ReplaceAll which used GenericReplaseAll
4. Replace which used GenericReplace
5. NoDuplicates
6. EraseAll which used GenericEraseAll
7. Erase which used GenericErase
8. staticIndexOf which used genericIndexOf
Need only little think :-)
Comment #13 by andrej.mitrovich — 2013-06-14T08:32:01Z