Re: A specifier readf() for BigInt

2015-02-16 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 16 February 2015 at 19:52:20 UTC, Dennis Ritchie wrote: Hi. And how to read Data from the input stream? import std.stdio; import std.bigint; void main() { BigInt n; readf( %?, n); writeln(n); } The readf function does not seem to support reading BigInts

Re: The best way to compare floating point values.

2015-02-14 Thread Ivan Kazmenko via Digitalmars-d-learn
There is an approxEqual in std.math, in addition in feqrel: http://dlang.org/phobos/std_math.html#.approxEqual It takes maximum absolute and relative difference as arguments.

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 31 January 2015 at 13:45:22 UTC, RuZzz wrote: I want to understand the correct architecture of the class. Sorry, you still did not state your problem (or what you are trying to achieve) clearly. Writing down a clear problem description is likely to get you halfway to the

Re: How to make a Currency class from std.BigInt?

2015-01-30 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 30 January 2015 at 20:34:53 UTC, RuZzz wrote: What do I need to learn? c[BTC][N-01] = 1.0002;//Error: cannot implicitly convert expression (1) of type double to axfinance.api.currencies.Currencies As I see it, there is no constructor in your class with a double argument.

Re: Getting DAllegro 5 to work in Windows

2014-12-25 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 24 December 2014 at 06:47:26 UTC, Joel wrote: I can't get implib.exe (http://ftp.digitalmars.com/bup.zip) to produce .lib files from dlls (https://www.allegro.cc/files/). I think it works for other people. Thanks for any help. Reading Part II of this answer on Stackoverflow

Re: printing array of strings with writefln?

2014-11-17 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 16 November 2014 at 15:08:10 UTC, JR wrote: On Sunday, 16 November 2014 at 14:16:55 UTC, Artem Tarasov wrote: writefln(%(%s-%), [a, b, c]) doesn't print the intended a-b-c but surrounds each string with double quotes - a-b-c, which I find inconsistent with the fact that

Re: Russian translation of the range term?

2014-11-17 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 12 November 2014 at 20:48:00 UTC, Jack Applegame wrote: интервал, область Thanks to all for the suggestions and reasoning! I don't yet see a word which clicks in this case, but we got multiple reasonable suggestions here. Perhaps I'll be fine with one of them. Ivan

Re: cannot sort an array of char

2014-11-11 Thread Ivan Kazmenko via Digitalmars-d-learn
IK For example, isRandomAccessRange[0] states the problem: IK - IK Although char[] and wchar[] (as well as their qualified IK versions including string and wstring) are arrays, IK isRandomAccessRange yields false for them because they use IK variable-length encodings (UTF-8 and UTF-16

Re: cannot sort an array of char

2014-11-11 Thread Ivan Kazmenko via Digitalmars-d-learn
IK Why is char [] so special that it can't be sorted? SS Because sort works on ranges, and std.range has the view that SS char[] is a range of dchar without random access. Nevermind SS what the compiler thinks :) SS SS I believe you can get what you want with SS std.string.representation: SS SS

Re: Russian translation of the range term?

2014-11-11 Thread Ivan Kazmenko via Digitalmars-d-learn
I was thinking about list comprehension, which is what programming on ranges is. Isn't it? list is a good term, but it's already taken. so naming range as list will create unnecessary confusion. alas. yet набор is short and easy, and it's not widely used, as set is translated as множество.

Re: cannot sort an array of char

2014-11-06 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 13:34:05 UTC, Marc Schütz wrote: On Wednesday, 5 November 2014 at 12:54:03 UTC, Ivan Kazmenko wrote: Hi! This gives an error (cannot deduce template function from argument types): - import std.algorithm; void main () { char [] c; sort

cannot sort an array of char

2014-11-05 Thread Ivan Kazmenko via Digitalmars-d-learn
Hi! This gives an error (cannot deduce template function from argument types): - import std.algorithm; void main () { char [] c; sort (c); } - Why is char [] so special that it can't be sorted? For example, if I know the array contains only ASCII characters, sorting

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 3 November 2014 at 20:03:03 UTC, Ali Çehreli wrote: On 11/03/2014 11:47 AM, Ivan Kazmenko wrote: On Monday, 3 November 2014 at 19:37:20 UTC, Ivan Kazmenko wrote: readf (%s, s); Worth noting: this reads to end-of-file (not end-of-line or whitespace), and reading the whole file

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 3 November 2014 at 20:10:02 UTC, Gary Willoughby wrote: On Monday, 3 November 2014 at 19:47:17 UTC, Ivan Kazmenko wrote: So, if there is an idiomatic way to read the whole file into a string which is Unicode-compatible, it would be great to learn that, too. Maybe something like

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 11:46:24 UTC, Kagamin wrote: https://issues.dlang.org/show_bug.cgi?id=12990 this? Similar, but not quite that. Bugs 12990 and 1448 (linked from there) seem to have Windows console as an important part of the process. For me, the example does not work even

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 13:01:48 UTC, anonymous wrote: On Monday, 3 November 2014 at 19:37:20 UTC, Ivan Kazmenko wrote: Hi! The following code does not correctly handle Unicode strings. - import std.stdio; void main () { string s; readf (%s, s); write (s); }

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 18:09:48 UTC, Ivan Kazmenko wrote: On Monday, 3 November 2014 at 20:10:02 UTC, Gary Willoughby wrote: On Monday, 3 November 2014 at 19:47:17 UTC, Ivan Kazmenko wrote: So, if there is an idiomatic way to read the whole file into a string which is

Reading unicode string with readf (%s)

2014-11-03 Thread Ivan Kazmenko via Digitalmars-d-learn
Hi! The following code does not correctly handle Unicode strings. - import std.stdio; void main () { string s; readf (%s, s); write (s); } - Example input (Test. in cyrillic): - Тест. - (hex: D0 A2 D0 B5 D1 81 D1 82 2E 0D 0A) Example output: -

Re: Reading unicode string with readf (%s)

2014-11-03 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 3 November 2014 at 19:37:20 UTC, Ivan Kazmenko wrote: readf (%s, s); Worth noting: this reads to end-of-file (not end-of-line or whitespace), and reading the whole file into a string was what I indeed expected it to do. So, if there is an idiomatic way to read the whole

Re: Learning to use ranges instead of arrays

2014-07-21 Thread Ivan Kazmenko via Digitalmars-d-learn
Also, there is std.array.array for the ranges you want to convert to arrays. For example, if a is an array, a.map!(x = x * 2).array produces an new array of doubled values (as opposed to a lazy range produced by std.algorithm.map).

Re: why does clearing an array set its capacity to 0?

2014-07-01 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 1 July 2014 at 13:03:54 UTC, Vlad Levenfeld wrote: I was mistaken earlier, decrementing the length counter also sets the capacity to 0. Besides just learning to use assumeSafeAppend (as mentioned already), I'd also recommend reading the article on D slices to deeper understand

Re: hijacking override from template mixin

2014-06-10 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 9 June 2014 at 16:13:50 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 15:54:21 UTC, Ivan Kazmenko wrote: I'd expect a multiple overrides of same function error, much like if I just paste the mixin code by hand. Is that a bug or working by design? In the latter case, please

hijacking override from template mixin

2014-06-09 Thread Ivan Kazmenko via Digitalmars-d-learn
The D language pays certain attention to avoiding hijacking [1]. So I was surprised when I hijacked a function override from a template mixin by mistake. Here is a commented example. The comments explain the relevant part of the life cycle of the program. - // Start with class A with

Re: Different random shuffles generated when compiled with gdc than with dmd

2014-06-01 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 31 May 2014 at 21:22:48 UTC, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: On 31/05/14 22:37, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: On 30/05/14 22:45, monarch_dodra via Digitalmars-d-learn wrote: Didn't you make changes to how and when the global PRNG is

<    1   2