Comment #0 by bearophile_hugs — 2015-10-21T07:37:10Z
This is a slow and naive function to reverse a BigInt:
import std.bigint: BigInt;
import std.conv: to;
import std.conv: text;
import std.range: retro;
BigInt rev(in BigInt n) {
return n.text.retro.text.BigInt;
}
void main() {
assert(125.BigInt.rev == 521);
}
But I'd like to avoid the second text conversion, and to write:
BigInt rev2(in BigInt n) {
return n.text.retro.BigInt;
}
In general in Phobos there are many functions (and constructors) that could and sometimes should be range-ifed. An obvious one is to make std.conv.to!() accept a lazy input too.
Comment #1 by jack — 2015-12-16T16:47:45Z
*** Issue 15234 has been marked as a duplicate of this issue. ***