conver BigInt to string
cym13 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Nov 6 03:50:21 PST 2015
On Friday, 6 November 2015 at 10:00:23 UTC, Namal wrote:
> On Thursday, 5 November 2015 at 17:40:12 UTC, bearophile wrote:
>> Namal:
>>
>>> Hello I am trying to convert BigInt to string like that while
>>> trying to sort it:
>>
>> void main() {
>> import std.stdio, std.algorithm, std.conv, std.bigint,
>> std.string;
>>
>> auto n = 17.BigInt ^^ 179;
>> n.text.dup.representation.sort().release.assumeUTF.writeln;
>> }
>>
>> Bye,
>> bearophile
>
> can I import libraries anywhere? Is this the proper way to do
> so?
You can, and some say you should. The thing is, if you use
templates and import the necessary libraries within the template
then the import occurs only if the template is instantiated which
can be a big gain. Phobos makes great use of this technique for
example.
More information about the Digitalmars-d-learn
mailing list