Bug 15229 – BigInt(Range of chars) too

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2015-10-21T07:37:00Z
Last change time
2016-04-29T11:18:59Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

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. ***
Comment #2 by jack — 2015-12-17T16:27:10Z
Comment #3 by github-bugzilla — 2016-04-29T11:18:58Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/dd0d1398317af539787b92ad68c84c1091d11f24 Fix Issue 15229: Refactored BigInt code to work with character ranges https://github.com/dlang/phobos/commit/8c3f3432370a33ce826f150231800e04fb6f2dfd Merge pull request #3876 from JackStouffer/bigint2 [issue 15229] Range-ified BigInt's Ctor to Accept Ranges of Characters