SO rotate question

Pelle pelle.mansson at gmail.com
Fri Sep 3 04:45:38 PDT 2010


On 09/03/2010 01:35 PM, bearophile wrote:
> Pelle:
>
>> bool isRotated(T)(T[] a, T[] b) {
>>       return a.length == b.length&&  (a.length == 0 ||
>> canFind(chain(a,a), b));
>> }
>
> Nice clean solution. I suggest to add "pure" and two "const" in the signature.
>
>
>> canFind isn't really the best possible name, is it?
>
> Some name/APIs of Phobos are not the best possible, they were often invented by a single person. I don't know if contains() or isIn() are better.
>
> Bye,
> bearophile

Heh, I actually tried that before posting, but chain doesn't seem to 
support const. :-)

Should probably be two forward ranges, not two arrays, as well.


More information about the Digitalmars-d-learn mailing list