Re: Map of functions

2018-12-14 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 14 December 2018 at 15:38:49 UTC, Giovanni Di Maria wrote: Hi Is there an utility to print the functions in a source file, for example: - main() --- calculate() - print() --- simulate() - print() . Thank you very much Giovanni Di Maria Do you really have a nested

Re: dmd64 on Windows: how?

2018-08-12 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 12 August 2018 at 03:49:04 UTC, Mike Parker wrote: On Saturday, 11 August 2018 at 19:50:30 UTC, Ivan Kazmenko wrote: I've installed the components shown in wiki image: v141 tools and the SDKs. VS 2017 Community includes everything you need. There's no reason to install the SDK

Re: dmd64 on Windows: how?

2018-08-11 Thread Ivan Kazmenko via Digitalmars-d-learn
Well, I tried all your suggestions. (Actually re-tried a few times.) Thanks, Laurent and Kagamin! On Friday, 10 August 2018 at 14:47:04 UTC, Laurent Tréguier wrote: Did you have a look at the wiki ? It looks like the image shows what needs to be installed:

dmd64 on Windows: how?

2018-08-10 Thread Ivan Kazmenko via Digitalmars-d-learn
Hi, How should I set up DMD to be able to `dmd -m64` on Windows nowadays? I usually download the 7z, but it broke when I replaced my Visual Studio with 2017 edition. Now, I tried the current 2.081.1 .exe installer. It didn't propose any additional 64-bit related options. After the

Re: how to correctly populate an array of dynamic closures?

2018-03-29 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 29 March 2018 at 15:38:14 UTC, ag0aep6g wrote: <...> With immutable, this is certainly a problem. https://issues.dlang.org/show_bug.cgi?id=2043 Wow, such history for the bug! Two possible workarounds: int delegate () [] iuns; foreach (i; 0..2) iuns ~= (j) { return () =>

how to correctly populate an array of dynamic closures?

2018-03-29 Thread Ivan Kazmenko via Digitalmars-d-learn
Here's a simplified example of what I want to achieve. I first create funs, an array of two delegates. I want funs[0] to always return 0 and funs[1] to always return 1. By assigning the constants directly (see the code below), I achieve exactly that. Now, I want to use a loop to assign the

Re: Why 2 ^^ 1 ^^ 2 = 2?

2017-10-27 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 26 October 2017 at 10:02:54 UTC, Kagamin wrote: On Sunday, 22 October 2017 at 22:28:48 UTC, Ivan Kazmenko wrote: Yeah, and a height-3 tower $a^{b^c}$ (TEX notation) Is $a^{b^c}$ the same as ${a^b}^c$ ? They are drawn slightly differently, so I suppose it's ambiguous indeed.

Re: Why 2 ^^ 1 ^^ 2 = 2?

2017-10-22 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 22 October 2017 at 14:44:04 UTC, Timon Gehr wrote: On 22.10.2017 16:20, Ilya Yaroshenko wrote: .. i thought it should be (2 ^^ 1) ^^ 2 = 4 2 ^^ (1 ^^ 2) == 2 It is standard for ^/**/^^ to be right-associative. (This is also the standard convention in mathematics.) Yeah, and a

Re: floating point value rounded to 6digits

2017-09-19 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 22:44:06 UTC, greatsam4sure wrote: On Tuesday, 19 September 2017 at 21:52:57 UTC, Ivan Kazmenko wrote: On Tuesday, 19 September 2017 at 20:47:02 UTC, greatsam4sure wrote: double value = 20.89766554373733; writeln(value); //Output =20.8977 How do I output the

Re: floating point value rounded to 6digits

2017-09-19 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 20:47:02 UTC, greatsam4sure wrote: double value = 20.89766554373733; writeln(value); //Output =20.8977 How do I output the whole value without using writfln,write or format. How do I change this default The default when printing floating-point numbers is to

Re: writeln() sometimes double prints from main() if I run a thread checking for input?

2017-08-31 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 31 August 2017 at 14:43:39 UTC, Steven Schveighoffer wrote: Just a thought, but the "double printing" could be a misunderstanding. It could be printing Output\nOutput2, but not getting the 2 out there. No no, it's four lines instead of three. If we change the lines to disjoint

Re: writeln() sometimes double prints from main() if I run a thread checking for input?

2017-08-31 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 30 August 2017 at 13:33:06 UTC, Ivan Kazmenko wrote: Interesting. As to what to do with it, no idea for now. At the very least we can issue a bug report, now that at least two people can reproduce it, so it is unlikely to be environment-dependent. Reported:

Re: writeln() sometimes double prints from main() if I run a thread checking for input?

2017-08-30 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 30 August 2017 at 13:24:55 UTC, Ivan Kazmenko wrote: On Wednesday, 30 August 2017 at 10:55:20 UTC, Timothy Foster wrote: import std.stdio, core.thread; void main(){ auto thread = new Thread().start; writeln("Output"); writeln("Output2");

Re: writeln() sometimes double prints from main() if I run a thread checking for input?

2017-08-30 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 30 August 2017 at 10:55:20 UTC, Timothy Foster wrote: import std.stdio, core.thread; void main(){ auto thread = new Thread().start; writeln("Output"); writeln("Output2"); writeln("Output3"); while(true){} } void func(){

Re: writeln() sometimes double prints from main() if I run a thread checking for input?

2017-08-30 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 30 August 2017 at 10:13:57 UTC, Timothy Foster wrote: I'm not sure if this is a known issue, or if I just don't understand how to use threads, but I've got writeln statements sometimes printing out twice in some areas of my code. <...> Does anyone know what is causing this or how

Re: Get complete function declaration

2017-07-18 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 13:35:49 UTC, SrMordred wrote: There is a way to get the full function(or any other structure) declaration with traits? Or I will have to mount it with std.traits functions? eg. void add(int x, int y){} GetFullFunctionDeclaration!add; //return "void add(int x, int

Re: Avoid if statements for checking neighboring indexes in a 2D array

2017-07-17 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 17 July 2017 at 07:14:26 UTC, Andrea Fontana wrote: Probably using ndslice library could help you! Unfortunately, that's not possible on most online contest platforms like Codeforces. For each programming language and compiler available, only the most basic package is usually

Re: Avoid if statements for checking neighboring indexes in a 2D array

2017-07-17 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 16 July 2017 at 21:50:19 UTC, kerdemdemir wrote: Process(row-1,column-1, maxrow, maxcolumn); Process(row,column-1, maxrow, maxcolumn); Process(row+1,column-1, maxrow, maxcolumn);

Re: Avoid if statements for checking neighboring indexes in a 2D array

2017-07-16 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 16 July 2017 at 10:37:39 UTC, kerdemdemir wrote: My goal is to find connected components in a 2D array for example finding connected '*' chars below. x x x x x x x x x x x x x x * * x x x x * * x x x x x * * x * x x x x x ... Is there any

Re: implib.exe no output files

2017-06-21 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 19 June 2017 at 23:11:29 UTC, Joel wrote: On Sunday, 18 June 2017 at 09:48:31 UTC, Ivan Kazmenko wrote: On Sunday, 18 June 2017 at 07:41:27 UTC, Joel wrote: I got the file here: http://ftp.digitalmars.com/bup.zip It works on other computers. I was trying to update to the latest

Re: implib.exe no output files

2017-06-18 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 18 June 2017 at 07:41:27 UTC, Joel wrote: I got the file here: http://ftp.digitalmars.com/bup.zip It works on other computers. I was trying to update to the latest DAllegro (https://github.com/SiegeLord/DAllegro5). Though, I used another computer for the lib files and still

Re: Help with an algorithm!

2017-06-15 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 15 June 2017 at 13:41:07 UTC, MGW wrote: On Thursday, 15 June 2017 at 13:16:24 UTC, CRAIG DILLABAUGH wrote: The purpose - search of changes in file system. Sorting is a slow operation as well as hashing. Creation of a tree, is equally in sorting. So far the best result:

Re: Help with an algorithm!

2017-06-15 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 15 June 2017 at 06:06:01 UTC, MGW wrote: There are two arrays of string [] mas1, mas2; Size of each about 5M lines. By the size they different, but lines in both match for 95%. It is necessary to find all lines in an array of mas2 which differ from mas1. The principal criterion -

Re: DMD [-O flag] vs. [memory allocation in a synchronized class]

2017-06-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 8 June 2017 at 15:35:06 UTC, Ivan Kazmenko wrote: Perhaps a regression should be filed, or searched for, at issues.dlang.org. I can do it, but not right now, and would be glad if someone beats me to it. Reported: https://issues.dlang.org/show_bug.cgi?id=17481

Re: DMD [-O flag] vs. [memory allocation in a synchronized class]

2017-06-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 8 June 2017 at 11:41:40 UTC, realhet wrote: I've managed to narrow the problem even more: //win32 dmd -O class Obj{ synchronized void trigger(){ new ubyte[1]; } } void main(){ auto k = new shared Obj; k.trigger; } This time I got a more sophisticated error message:

Re: Rosetta Commatizing numbers

2017-06-01 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 1 June 2017 at 08:45:23 UTC, Solomon E wrote: On Wednesday, 31 May 2017 at 15:44:51 UTC, Ivan Kazmenko wrote: So, two custom calls, two minor changes, no sweat. Is everything right now? Even if not: that was fast, we can do another iteration. When we have a short

Re: Rosetta Commatizing numbers

2017-05-31 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 13:27:24 UTC, Solomon E wrote: Fine, by the numbers: 1. pi has the commas start at the wrong digit, and doesn't follow the explicit instructions to use spaces as the separator and a grouping of 5 Can be solved by calling the function with a right set of

Re: Rosetta Commatizing numbers

2017-05-30 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 04:31:14 UTC, Ivan Kazmenko wrote: Now, where is the old version wrong? ... Actually, it also changes every number in the string, not only the first one as required. Because of that, it also fails the "do not touch the exponent" requirement. Sadly, both are

Re: Rosetta Commatizing numbers

2017-05-30 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 30 May 2017 at 10:54:49 UTC, Solomon E wrote: I ran into a Rosetta code solution in D that had obvious errors. It's like the author or the previous editor wasn't even trying to do it right, like a protest against how many detailed rules the task had. I assumed that's not the way we

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-10 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 12:40:41 UTC, k-five wrote: I have a line of code that uses "to" function in std.conv for a purpose like: int index = to!int( user_apply[ 4 ] ); // string to int When the user_apply[ 4 ] has value, there is no problem; but when it is empty: "" it throws an

Re: Problem with using readln.

2017-04-30 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 30 April 2017 at 02:07:48 UTC, JV wrote: Hello i'm kinda new to D language and i wanted to make a simple program but somehow my input does no go to my if statements and just continues to ask for the user to input.Kindly help me One way would be: import std.stdio; int x;

Re: Can you read the next line while iterating over byLine?

2017-02-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 2 February 2017 at 19:34:37 UTC, John Doe wrote: Thanks readln is perfect. Since I am calling readln in different places and I always need to remove the newline character I have line=line[0..$-1] all over my code. Is there are better way? "readln.strip" gives the line without

Re: Associative array literal: length wrong when duplicate keys found

2017-02-02 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 31 January 2017 at 19:45:33 UTC, Ivan Kazmenko wrote: On Tuesday, 31 January 2017 at 17:20:00 UTC, John Colvin wrote: It's a bug, please report it. The initializer should be statically disallowed. Anyway, I'll file a bug report. Hmm, found it:

Re: Associative array literal: length wrong when duplicate keys found

2017-01-31 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 31 January 2017 at 17:20:00 UTC, John Colvin wrote: It's a bug, please report it. The initializer should be statically disallowed. Adding a .dup works around the problem. OK. Hmm, but the real use case was a bit more complicated, more like: - int n = 10; foreach (i; 0..n)

Re: Partial arrays reclaimed?

2017-01-31 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 27 January 2017 at 23:22:17 UTC, Nick Sabalausky wrote: Suppose an array is being used like a FIFO: --- T[] slice; // Add: slice ~= T(); // Remove: slice = slice[1..$]; --- Assuming of course there's no other references to the memory, as

Associative array literal: length wrong when duplicate keys found

2017-01-31 Thread Ivan Kazmenko via Digitalmars-d-learn
Hi. I wanted to check whether a few variables of the same type are all distinct, in a quick and dirty way. I tried to do it similar to Python's "len(set(value_list)) == len(value_list)" idiom by using an associative array (AA). At this point, I found out that when initializing the AA with

Re: Yield from function?

2017-01-31 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 30 January 2017 at 11:03:52 UTC, Profile Anaysis wrote: I need to yield from a complex recursive function too allow visualizing what it is doing. e.g., if it is a tree searching algorithm, I'd like to yield for each node so that the current state can be shown visually. I realize

Re: size of a string in bytes

2017-01-28 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 28 January 2017 at 15:32:33 UTC, Nestor wrote: I want to know variable size in memory. For example, say I have an UTF-8 string of only 2 characters, but each of them takes 2 bytes. string length would be 2, but the content of the string would take 4 bytes in memory (excluding

Re: Trying to understand multidimensional arrays in D

2017-01-26 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 26 January 2017 at 05:20:07 UTC, Profile Anaysis wrote: (On the contrary, declarations in C or C++ looks rather unintuitive from this perspective: `T a[4][5][6]` is means that `a` is an array of 4 arrays of 5 arrays of 6 arrays of `T`. Note how we have to read left-to-right but

Re: Trying to understand multidimensional arrays in D

2017-01-25 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 26 January 2017 at 01:47:53 UTC, Profile Anaysis wrote: does this mean that have int[][4][4] matrix_history; backwards? int[4][4][] matrix_history; this creates even a more set of problems. In short, you are right, `int[4][4][]` is a dynamic array of `int[4][4]`. In

Re: switch to member

2017-01-14 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 14 January 2017 at 11:32:10 UTC, Marc Schütz wrote: You can utilize a little-known `switch` syntax trick in combination with `foreach`. Because a `foreach` over tuples is unrolled at compile time, it works even if your fields don't have exactly the same types: That looks

Re: opOpAssign on object properties

2017-01-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 8 January 2017 at 18:23:34 UTC, collerblade wrote: On Sunday, 8 January 2017 at 10:03:50 UTC, Ivan Kazmenko wrote: On Sunday, 8 January 2017 at 09:22:12 UTC, collerblade wrote: [...] 1. If you want the member variable to change, naturally, you should provide a getter property

Re: opOpAssign on object properties

2017-01-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 8 January 2017 at 09:22:12 UTC, collerblade wrote: How can i do opOpAssign with properties?? 1. If you want the member variable to change, naturally, you should provide a getter property which returns a reference to that variable: ref Point location() @property {

Re: Adding linker paths with spaces using dmd and msvc toolchain

2016-12-30 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 30 December 2016 at 05:24:56 UTC, Jeremy DeHaan wrote: On Friday, 30 December 2016 at 04:56:59 UTC, Jerry wrote: On Friday, 30 December 2016 at 03:51:13 UTC, Jeremy DeHaan wrote: How does one correctly add a linker path that has spaces? The quotes get consumed by the command line.

Re: How to list aggregate members in order of declaration at compile time?

2016-11-11 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 11 November 2016 at 22:04:37 UTC, Jonathan M Davis wrote: ... I expect that it never occurred to Walter to specify that the order of the members mattered with tupleof and that that's why the spec doesn't say. So, use tupleof, and you can create an enhancement request in bugzilla

Re: How to list aggregate members in order of declaration at compile time?

2016-11-11 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 10 November 2016 at 10:16:44 UTC, Ivan Kazmenko wrote: I want to somehow list members of a class in the order of their declaration. Bump. Anyone? I've met my immediate goal by other means, but the general question remains. If classes are no-go, basically, any aggregate will

How to list aggregate members in order of declaration at compile time?

2016-11-10 Thread Ivan Kazmenko via Digitalmars-d-learn
Hi. I want to somehow list members of a class in the order of their declaration. The immediate goal is to generate a few functions, like the "default" constructor for structs but only with all the fields, or the "reader" function, but I'm interested in the general question as well. I can

Re: Newbie: Error parsing csv file with very long lines

2016-04-23 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 23 April 2016 at 10:40:13 UTC, salvari wrote: It seems to be really simple, I read the columns name with no problem. But as soon as the program parses the first line of data, the array containing the columns names seems to be overwrited. Another possibility yet not mentioned is

Re: Ada-Style Modulo Integer Types

2016-04-22 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 22 April 2016 at 17:37:44 UTC, Nordlöw wrote: Have anybody implement Ada-style modulo types https://en.wikibooks.org/wiki/Ada_Programming/Types/mod I've implemented a proof-of-concept for algorithmic programming competitions [1]. In these competitions, quite a few problems ask to

Re: 111

2016-02-21 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 21 February 2016 at 12:35:31 UTC, Lisa wrote: ... Is there smth wrong again? Yes. As a programmer, most of the time, you will have to try your programs by yourself before you consider them correct. Now, run a compiler, and it complains: - main.d(20): Error: cannot return

Re: 111

2016-02-20 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 20 February 2016 at 04:15:50 UTC, Lisa wrote: module main; import std.stdio; import std.math; int main() { int A, B, C; writef("A = "); readf("%lf", %A); writef("B = "); readf("%lf", %B); writef("C1= "); readf("%lf", %C);

Re: 111

2016-02-19 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 19 February 2016 at 23:56:29 UTC, Lisa wrote: Can you please help me and explain how to create a program, which would find area of triangle and its perimeter? First, one can't find these unless something is given. So, what is given: sides? angles? two-dimensional coordinates?

Re: inner functions calling each other - how to do this with inner struct?

2016-02-03 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 15:09:35 UTC, Adam D. Ruppe wrote: Read my post here: http://stackoverflow.com/questions/34398408/struct-declaration-order/34398642#34398642 then see if you can use the same reasoning on your problem. This indeed works without any other tricks such as

Re: Get the return type of the function

2016-02-03 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 22:09:37 UTC, sigod wrote: On Wednesday, 3 February 2016 at 19:21:06 UTC, Meta wrote: Ah, I see. I'd like to test something; can you please change `(a) => a * a` to `(int a) => a * a` and post the results? This works. http://dpaste.dzfl.pl/92c254ef6cf6

Re: merging map/filter/reduce/... in D

2016-01-28 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 29 January 2016 at 07:17:04 UTC, glathoud wrote: I have the impression that function implementations are not merged: return fun0(fun1(a)); For example, fun1(a) outputs a temporary array, which is then used as input for fun0. Merging the implementations of fun0 and fun1 would

Re: Is this rdmd bug or my fault ?

2016-01-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 8 January 2016 at 15:45:52 UTC, zabruk70 wrote: Should i create bugreport, or this is my mistake? Same here: rdmd moduleA.d works. rdmd -g moduleA.d produces a linker error. What's more: rdmd -m64 -g moduleA.d fails, and rdmd -m64 moduleA.d also fails. I have dmd 2.069.2 here.

Re: regex - match/matchAll and bmatch - different output

2016-01-02 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 1 January 2016 at 12:29:01 UTC, anonymous wrote: On 30.12.2015 12:06, Ivan Kazmenko wrote: As you can see, bmatch (usage discouraged in the docs) gives me the result I want, but match (also discouraged) and matchAll (way to go) don't. Am I misusing matchAll, or is this a bug?

Re: regex - match/matchAll and bmatch - different output

2015-12-31 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 30 December 2015 at 11:06:55 UTC, Ivan Kazmenko wrote: ... As you can see, bmatch (usage discouraged in the docs) gives me the result I want, but match (also discouraged) and matchAll (way to go) don't. Am I misusing matchAll, or is this a bug? Reported as

regex - match/matchAll and bmatch - different output

2015-12-30 Thread Ivan Kazmenko via Digitalmars-d-learn
Hi, While solving Advent of Code problems for fun (already discussed in the forum: http://forum.dlang.org/post/cwdkmblukzptsrsrv...@forum.dlang.org), I ran into an issue. I wanted to test for the pattern "two consecutive characters, arbitrary sequence, the same two consecutive characters".

Re: Lots of D code

2015-12-28 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 28 December 2015 at 14:24:04 UTC, Basile B. wrote: On Wednesday, 23 December 2015 at 00:59:53 UTC, steven kladitis wrote: ... All of the programs are from RosettaCode.org. The script to compile them generates a log file and you will see a few that the linker just stops No idea

Re: Is it possible to elegantly create a range over a binary heap?

2015-12-28 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 28 December 2015 at 12:58:36 UTC, Gary Willoughby wrote: On Sunday, 27 December 2015 at 22:42:21 UTC, Ivan Kazmenko wrote: Or do you mean you want to print variables in order without modifying the array? Sounds like this would require at least N log N time and N additional memory

Re: Reducing array.length triggers reallocation

2015-12-27 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 27 December 2015 at 22:36:32 UTC, Ali Çehreli wrote: [Several hours later...] You know what... I bet there is no actual allocation at all. I think what happens is, the code calls GC.realloc(24) and realloc() does not do anything. However, it still reports to the profiler that

Re: Is it possible to elegantly create a range over a binary heap?

2015-12-27 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 27 December 2015 at 20:01:47 UTC, Gary Willoughby wrote: On Sunday, 27 December 2015 at 17:23:35 UTC, Gary Willoughby wrote: I have a binary tree storing ints implemented using an array. The internal state looks like this: 8,7,6,4,1,3,5,2 When extracting this data, it is returned

Re: DMD -L Flag, maybe a bug?

2015-12-26 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 26 December 2015 at 01:04:57 UTC, Bubbasaur wrote: It's almost like the example in the URL you showed: dmd test.d -LC:/gtkd/src/build/GtkD.lib Note that -L passes flags (options) but not necessarily arguments or paths. For example, I use "dmd -L/STACK:268435456" by default

Re: Most performant way of converting int to string

2015-12-24 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 22 December 2015 at 19:50:28 UTC, Daniel Kozák wrote: V Tue, 22 Dec 2015 18:39:16 + Ivan Kazmenko via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> napsáno: Does DMD, or Phobos function to!(string), do anything like that? The number of possible bases is not

Re: Most performant way of converting int to string

2015-12-22 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 22 December 2015 at 18:11:24 UTC, rumbu wrote: On Tuesday, 22 December 2015 at 17:15:27 UTC, Andrew Chapman wrote: Sorry if this is a silly question but is the to! method from the conv library the most efficient way of converting an integer value to a string? e.g. string s =

Re: AA struct hashing bug?

2015-12-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 8 December 2015 at 11:45:25 UTC, Random D user wrote: Ok. This is minimal app that crashes for me. If someone could try this: At the very least, there is no crash when changing `struct Foo` to `static struct Foo`, so it is perhaps related to `Foo` being an inner struct with a

Re: AA struct hashing bug?

2015-12-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 8 December 2015 at 11:45:25 UTC, Random D user wrote: Ok. This is minimal app that crashes for me. If someone could try this: OK, this at least reproducibly crashes here, too (-m32 and -m64 on Windows, tried dmd 2.069.0 and 2.067.1).

Re: AA struct hashing bug?

2015-12-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 8 December 2015 at 11:45:25 UTC, Random D user wrote: Ok. This is minimal app that crashes for me. If someone could try this: Interesting. With dmd 2.064.2, your example compiles and runs fine. With dmd 2.065.0, it does not compile, complaining that there is no opCmp for `Foo`s.

Re: AA struct hashing bug?

2015-12-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 8 December 2015 at 11:04:49 UTC, Random D user wrote: On Tuesday, 8 December 2015 at 01:23:40 UTC, Ivan Kazmenko wrote: On Monday, 7 December 2015 at 22:03:42 UTC, Alex Parrill wrote: On Monday, 7 December 2015 at 18:48:18 UTC, Random D user Tested the same code with -m32 and -m64

Re: AA struct hashing bug?

2015-12-07 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 7 December 2015 at 22:03:42 UTC, Alex Parrill wrote: On Monday, 7 December 2015 at 18:48:18 UTC, Random D user wrote: struct Foo { this( int k ) { a = k; } int a; } Foo foo; int[ Foo ] map; map[ foo ] = 1; // Crash! bug? // This also crashes. I believe

Re: foreach multiple loop sugar

2015-08-18 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 18 August 2015 at 16:51:01 UTC, ixid wrote: On Tuesday, 18 August 2015 at 16:02:42 UTC, cym13 wrote: On Tuesday, 18 August 2015 at 15:51:55 UTC, ixid wrote: Though sugar seems to be somewhat looked down upon I thought I'd suggest this- having seen the cartesianProduct function

Re: forward range properties with alias this - how?

2015-07-29 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 29 July 2015 at 12:25:14 UTC, Marc Schütz wrote: On Tuesday, 28 July 2015 at 21:25:23 UTC, Ivan Kazmenko wrote: Hello, I wrap an array into a struct. Then I use alias this to expose the array functionality. Sadly, range properties of the array are not forwarded, and so I

Re: forward range properties with alias this - how?

2015-07-29 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 29 July 2015 at 23:54:29 UTC, Ivan Kazmenko wrote: On Wednesday, 29 July 2015 at 12:25:14 UTC, Marc Schütz wrote: On Tuesday, 28 July 2015 at 21:25:23 UTC, Ivan Kazmenko wrote: ... Perhaps I still don't implement save() correctly. The line @property auto save() {return

forward range properties with alias this - how?

2015-07-28 Thread Ivan Kazmenko via Digitalmars-d-learn
Hello, I wrap an array into a struct. Then I use alias this to expose the array functionality. Sadly, range properties of the array are not forwarded, and so I can't use the struct as an array with functions from std.algorithm and std.range. - import std.range, std.stdio; struct S {

Re: partialShuffle only shuffles subset.

2015-05-19 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 19 May 2015 at 10:00:33 UTC, BlackEdder wrote: The documentation seems to indicate that partialShuffle: Partially shuffles the elements of r such that upon returning r[0..n] is a random subset of r, (which is what I want), but it seems that partialShuffle actually only shuffles the

Re: Feature or bug: print braces

2015-05-15 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 14 May 2015 at 00:29:06 UTC, Dennis Ritchie wrote: Why doesn't the compiler produces an error? - import std.stdio; void main() { writeln({}); } - http://ideone.com/qTZCAd Somehow reminds me of this lambda:

Re: Possible to write a classic fizzbuzz example using a UFCS chain?

2015-04-28 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 28 April 2015 at 10:46:54 UTC, Gary Willoughby wrote: After reading the following thread: http://forum.dlang.org/thread/nczgumcdfystcjqyb...@forum.dlang.org I wondered if it was possible to write a classic fizzbuzz[1] example using a UFCS chain? I've tried and failed. [1]:

Re: Convert hex to binary

2015-04-24 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 24 April 2015 at 18:55:07 UTC, Steven Schveighoffer wrote: Thanks to all of you for the solutions, but what if the hex-string exceeds the limit of ulong, for instance 123456789ABCDEF0123456789ABCDEF1234. How to convert them to a ulong-array? Well, technically, a hex string can be

Re: Formatted output ranges

2015-04-20 Thread Ivan Kazmenko via Digitalmars-d-learn
Yes, it's a lot better but I did not get to concatenate the string ;; in each paragraph: - import std.conv, std.stdio, std.range, std.string; void main() { auto a = iota(10, 1101).text; a = a[1 .. $ - 1], a ~= '.'; writeln(wrap(a, 30)); } -

Re: Formatted output ranges

2015-04-17 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 11 April 2015 at 22:45:39 UTC, Dennis Ritchie wrote: I also want to know whether it is possible to D somehow set the maximum width of the print string in characters? - void main() { import std.stdio, std.range; writefln(;; %(%s, %))., iota(10, 1101)); } -

Re: Two-dimensional slices in D

2015-04-14 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 14 April 2015 at 14:21:41 UTC, Dennis Ritchie wrote: writefln([%([%(%s, %)]%|\n %)], [a[4][4 .. $], a[5][4 .. $], a[6][4 .. $], a[7][4 .. $]]); At least this can be done as - writefln([%([%(%s, %)]%|\n %)], a[4..8].map !(b = b[4 .. $])); -

Re: Extracting Sorted Storage from BinaryHeap

2015-03-29 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 29 March 2015 at 20:05:22 UTC, Nordlöw wrote: What's the most efficient way to extract a the storage from a BinaryHeap and then sort it? Is there a better way other than binaryHeap.release.sort than makes use of the heap property? For example while (!binaryHeap.empty)

Re: C# to D

2015-03-25 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 25 March 2015 at 20:02:20 UTC, Ivan Kazmenko wrote: Will file an issue soon. Here it is: https://issues.dlang.org/show_bug.cgi?id=14340 And another one, a 2.067 regression: https://issues.dlang.org/show_bug.cgi?id=14341

Re: C# to D

2015-03-25 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 25 March 2015 at 20:09:53 UTC, bearophile wrote: Dennis Ritchie: A more effective solution for C ++: #include iostream #include vector #include range/v3/all.hpp int main() { using namespace ranges; auto rng = istreamint( std::cin ) | to_vector |

Re: C# to D

2015-03-25 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 25 March 2015 at 20:17:57 UTC, bearophile wrote: Ivan Kazmenko: (1) For me, the name of the function is obscure. Something like sortBy would be a lot easier to find than schwartzSort. I've asked to change the name of that function for years. But Andrei Alexandrescu is a

Re: C# to D

2015-03-25 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 25 March 2015 at 19:32:43 UTC, Dennis Ritchie wrote: On Wednesday, 25 March 2015 at 19:01:43 UTC, bearophile wrote: One solution: Thanks. On Wednesday, 25 March 2015 at 19:03:27 UTC, bearophile wrote: But calling count for each item is not efficient (in both C# and D). If your

Re: C# to D

2015-03-25 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 25 March 2015 at 20:02:20 UTC, Ivan Kazmenko wrote: (2) The documentation says it is more efficient than the first version in the number of comparisons (verbose lambda with plain sort) [1], but I don't get how it is possible: unless we know than (not pred1(a,b)) and (not

Re: BigInt and xor

2015-03-24 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 15:45:36 UTC, Dennis Ritchie wrote: Tell me, please, how can I replace this code? import std.conv : to; import std.bigint : BigInt; import std.string : format; import std.stdio : writeln; void main() { BigInt[10] bitArr; ulong n =

Re: refactoring issues

2015-03-22 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 20 March 2015 at 18:37:57 UTC, Vladimir Panteleev wrote: On Friday, 20 March 2015 at 18:36:19 UTC, Vladimir Panteleev wrote: On Friday, 20 March 2015 at 18:05:07 UTC, Ivan Kazmenko wrote: Thanks. I was able to reproduce the workflow you showed in the gif to the part where an error

Re: The difference in string and char[], readf() and scanf()

2015-03-21 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 21 March 2015 at 14:31:20 UTC, Dennis Ritchie wrote: In C++ it is fully working: char s[25], t[25]; scanf(%s%s, s, t); Indeed. Generate a 10-character string: - import std.range, std.stdio; void main () {'a'.repeat (10).writeln;} - Try to copy it with D

Re: The difference in string and char[], readf() and scanf()

2015-03-21 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 21 March 2015 at 16:34:44 UTC, Dennis Ritchie wrote: And why in D copied only the first 32767 characters of the string? I'm more days couldn't understand what was going on... To me, it looks like a bug somewhere, though I don't get where exactly. Is it in bits of DigitalMars

Re: refactoring issues

2015-03-20 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 19 March 2015 at 16:06:31 UTC, Vladimir Panteleev wrote: On Thursday, 19 March 2015 at 14:32:53 UTC, Ivan Kazmenko wrote: Hey, I also happen to use Far Manager and its internal editor, at least for simple projects. Is that dcheck triggering a Far plugin? I have a bit of

Re: refactoring issues

2015-03-19 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 19 March 2015 at 10:21:09 UTC, Vladimir Panteleev wrote: On Tuesday, 17 March 2015 at 15:11:02 UTC, Ivan Kazmenko wrote: For the former problem, is there a tool which jumps out and tells you use Phobos without importing things properly, or suggests a Phobos import by the name of

refactoring issues

2015-03-17 Thread Ivan Kazmenko via Digitalmars-d-learn
Hi, I was just refactoring a project to compile under 2.067. The fixes themselves were trivial: just adding import std.traits; to some files. Apparently its pieces were publicly imported by another module in 2.066. So, it's the right fix anyway. Understanding what happened, however, took

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

  1   2   >