Re: Idiomatic adjacent_difference

2015-10-16 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Friday, 16 October 2015 at 11:43:16 UTC, Guillaume Chatelet wrote: On Friday, 16 October 2015 at 11:38:35 UTC, John Colvin wrote: Nice ! I wanted to use lockstep(r, r.dropOne) but it doesn't return a Range :-/ It has to be used in a foreach. Instead of lockstep you can always use zip (whi

Frequent cannot deduce function from argument types

2015-10-16 Thread Edwin van Leeuwen via Digitalmars-d-learn
Just wondering if anyone has any tips on how to solve/avoid "cannot deduce function from argument types" when relying on template programming. I run into these problems all the time. Current one was when I tried: ``` auto ys = NumericLabel(groupedAes.front.map!((t)=>t.y)); ``` NumericLabel

Merging two named Tuples

2015-10-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
I am trying to write a function to merge two named structs, but am completely stuck on how to do that and was wondering if anyone good provide any help. I know I can access the different names with tup.fieldNames, but basically can't work out how to use that to build the new return type. Below

Re: Merging two named Tuples

2015-10-29 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Saturday, 24 October 2015 at 11:04:14 UTC, Edwin van Leeuwen wrote: I am trying to write a function to merge two named structs, but am completely stuck on how to do that and was wondering if anyone good provide any help. I know I can access the different names with tup.fieldNames, but basica

Re: Merging two named Tuples

2015-10-29 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 29 October 2015 at 19:42:10 UTC, anonymous wrote: `tup` is an ordinary (run time, dynamic) string to the type system. You can't mixin those. You can only mixin static values (enum, static immutable, CTFE results). The code you're generating doesn't depend on `base` and `other`. A

Re: foreach loop

2015-11-03 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 3 November 2015 at 15:29:31 UTC, Namal wrote: writefln("Count is: %s", arr .filter!(a => a==true) .sum); // Note: std.algorithm.sum is the same as // std.algorithm.reduce!((a,b)=a+b); Shouldn't you be using walkLength instead of sum, since you are counting the left over valu

Re: foreach loop

2015-11-03 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 3 November 2015 at 16:55:44 UTC, wobbles wrote: On Tuesday, 3 November 2015 at 15:42:16 UTC, Edwin van Leeuwen wrote: On Tuesday, 3 November 2015 at 15:29:31 UTC, Namal wrote: writefln("Count is: %s", arr .filter!(a => a==true) .sum); // Note: std.algorithm.sum is the same as /

Re: my first D program (and benchmark against perl)

2015-11-11 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 11 November 2015 at 13:32:00 UTC, perlancar wrote: for (int rownum=0; rownum < table.length; rownum++) { res ~= "|"; for (int colnum=0; colnum < table[rownum].length; colnum++) { res ~= leftJustify(table[rownum][colnum], widths[colnum]);

Re: CMake support for D

2016-01-04 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 4 January 2016 at 12:40:23 UTC, Dibyendu Majumdar wrote: Thanks for suggesting dub, will check it out. Also premake seems to support D so that is another option. Another alternative is reggae which supports mixed code base: https://github.com/atilaneves/reggae and can generate

Re: Speed of csvReader

2016-01-21 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 21 January 2016 at 09:39:30 UTC, data pulverizer wrote: StopWatch sw; sw.start(); auto buffer = std.file.readText("Acquisition_2009Q2.txt"); auto records = csvReader!row_type(buffer, '|').array; sw.stop(); Is it csvReader or readText that is slow? i.e. could you move sw

Re: Speed of csvReader

2016-01-21 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 21 January 2016 at 15:17:08 UTC, data pulverizer wrote: On Thursday, 21 January 2016 at 14:56:13 UTC, Saurabh Das wrote: @Edwin van Leeuwen The csvReader is what takes the most time, the readText takes 0.229 s The underlying problem most likely is that csvReader has (AFAIK) never

Re: Speed of csvReader

2016-01-22 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Friday, 22 January 2016 at 02:16:14 UTC, H. S. Teoh wrote: On Thu, Jan 21, 2016 at 04:50:12PM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] > > https://github.com/quickfur/fastcsv [...] Fixed some boundary condition crashes and reverted doubled quote handling in unquoted fie

Re: String joining an array of structs or class instances implementing toString?

2016-02-11 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 11 February 2016 at 12:44:15 UTC, pineapple wrote: It feels like there should be an out-of-the box way to do this but I haven't been able to find it? Help? This is the thing that I want to do: struct example{ const string str; //this(string str){ this.str = str; } stri

Re: String joining an array of structs or class instances implementing toString?

2016-02-11 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 11 February 2016 at 13:43:49 UTC, pineapple wrote: Thanks! Does the map function iterate without constructing an extra list in-memory? Yes, it is lazy, so it only calls toString when the result is actually used (by the join call). In case you do need to create an extra list you

Re: Installing DUB on OSX

2016-02-18 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 18 February 2016 at 09:25:00 UTC, Joel wrote: On Thursday, 18 February 2016 at 08:24:34 UTC, Jacob Carlborg wrote: On 2016-02-18 08:11, Joel wrote: I had dub installed in a folder that meant I had to put 'sudo dub' to run it. I've tried to fix the problem, but where do you put it

Re: Is DUB the best place to get examples of "Best of" D code?

2016-02-28 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Sunday, 28 February 2016 at 05:59:39 UTC, WhatMeWorry wrote: If so, is there a way to do a global search of all projects in DUB? If you just want to search through package names and descriptions you can use the search box at the top right of code.dlang.org. If you want to search through

Re: Am I right understand the dub.json system?

2016-02-29 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 29 February 2016 at 12:27:04 UTC, Suliman wrote: For example I have got app that depended on DDBC. In configuration section DDBC related on: "libs-posix": [ "sqlite3", "pq" ] Does it's mean that it will try to find this 2 libs in any case? Even I do not use them. If I do not need

Re: Am I right understand the dub.json system?

2016-02-29 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 29 February 2016 at 12:45:36 UTC, Suliman wrote: On Monday, 29 February 2016 at 12:34:02 UTC, Edwin van Leeuwen wrote: Should it be like this? http://www.everfall.com/paste/id.php?80k9jsgdx6o3 "versions": ["VibeCustomMain"], "versions": ["USE_MYSQL"], As far as I know all

Re: Why file.exists of relative path on Linux always return false?

2016-02-29 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 29 February 2016 at 14:58:46 UTC, Alex Parrill wrote: On Monday, 29 February 2016 at 14:50:51 UTC, Suliman wrote: I am trying to check relative path on Linux for exists. string mypath = "~/Documents/imgs"; ~ is expanded by your shell. It is not a relative path, and system calls do

Re: Warning: statement is not reachable

2016-03-02 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 21:30:44 UTC, Tamas wrote: My d code doesn't compile using ldc2 1.0.0-alpha or anything above DMD v2.068.0 Using these compilers I get a lot of "Warning: statement is not reachable". Then the both compiler crashes. ldc2 -w reach.d dmd -w reach.d reach.d: str

Re: Warning: statement is not reachable

2016-03-02 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 21:30:44 UTC, Tamas wrote: foreach(attr; __traits(getAttributes, S)) { static if (is(attr == Tag)) { return true; } } return false; }(); } void main() { static @Tag struct MyStru

Re: Memory Efficient HashSet

2016-03-08 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 8 March 2016 at 08:12:04 UTC, Nordlöw wrote: Has anybody put together a memory-efficient D-implementation of a HashSet Something like sparse_hash_set<> contained in https://github.com/sparsehash/sparsehash but in D. There is an implementation in: code.dlang.org/packages/emsi_co

Re: How to sort a range

2016-03-09 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 9 March 2016 at 03:05:52 UTC, rcorre wrote: I was in a situation where I wanted to remove duplicates from an OnlyResult. To do this with uniq, I needed to sort it. OnlyResult doesn't satisfy the template constraints of sort, but this seems easy enough to fix. I made front, back, a

Re: How to sort a range

2016-03-09 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 9 March 2016 at 12:21:55 UTC, rcorre wrote: If you are looking for a lazy uniq that works on non sorted ranges, I implemented one not to long ago: http://github.com/BlackEdder/ggplotd/blob/master/source/ggplotd/range.d That sounds like the kind of thing I was looking for. I'll ta

Re: How to sort a range

2016-03-09 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 9 March 2016 at 13:04:31 UTC, rcorre wrote: On Wednesday, 9 March 2016 at 12:31:18 UTC, Edwin van Leeuwen wrote: On Wednesday, 9 March 2016 at 12:21:55 UTC, rcorre wrote: If you are looking for a lazy uniq that works on non sorted ranges, I implemented one not to long ago: http:/

Re: How to sort a range

2016-03-09 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 9 March 2016 at 15:39:55 UTC, rcorre wrote: On Wednesday, 9 March 2016 at 14:28:11 UTC, cym13 wrote: Still curious as to why it fails; maybe the range is getting copied at some point? I guess I need to step through it. I did try different SwapStrategies with no luck. Since you

Re: Obtaining argument names in (variadic) functions

2016-03-18 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 17 March 2016 at 13:53:00 UTC, JR wrote: Interesting, any idea if it is possible to do assignment within template.. Either: printVars!(int abc=5,string def="58")(); or something like printVars!("abc","def",ghi)(5,"58"); What would the use-cases for those be? I don't think the

Re: Obtaining argument names in (variadic) functions

2016-03-19 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 20:53:42 UTC, JR wrote: void printVars(Args...)() if (Args.length > 0) { import std.stdio : writefln; foreach (i, arg; Args) { writefln("%s\t%s:\t%s", typeof(Args[i]).stringof, Args[i].stringof, arg); } } void main() { int abc = 3;

Re: Gdmd compiling error

2016-03-19 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 12:17:42 UTC, Orkhan wrote: On Tuesday, 15 March 2016 at 18:26:48 UTC, Ali Çehreli wrote: I don't know where from shpuld I get help. Thanks. Is the xcomm library available somewhere, maybe if we had a link to the original documentation we could help.

Re: Something wrong with GC

2016-03-22 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 22 March 2016 at 13:46:41 UTC, stunaep wrote: public class Example2 { private int one; private int two; public this(int one, int two) { this.one = one; this.two = two; } } in a tree map and list of som

Re: iota result as member variable

2016-03-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 24 March 2016 at 06:54:25 UTC, Alex wrote: Hi everybody, doing some optimization on my code, I faced some strange question: how to save a iota result in a class member? Say I have class A { ??? member; auto testIter4() { return iota(0,5); } } void main()

Re: Usage of custom class with JSONValue

2016-03-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 24 March 2016 at 08:15:12 UTC, Andre wrote: Hi, I have a class which has already an alias this to a string array, so I can use it in a foreach loop. class MyClass { string[] _data; alias _data this; // ... } void main() { import std.json;

Re: Usage of custom class with JSONValue

2016-03-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 24 March 2016 at 11:39:13 UTC, arturg wrote: isnt alias this supposed to do this implicitly? convert this auto jsValue = JSONValue(new MyClass()); into this auto jsValue = JSONValue((new MyClass())._data); Good point, I did not catch that. That indeed should work and seems to be

Re: infer type argument in classe constructor?

2016-03-29 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 29 March 2016 at 10:13:28 UTC, Puming wrote: Hi, I'm writing a generic class: ```d struct Message { ... } class Decoder(MsgSrc) { } ``` When using it, I'd have to include the type of its argument: ``` void main() { Message[] src = ...; auto decoder = new Decoder!(Message[

Read only delegate

2016-04-04 Thread Edwin van Leeuwen via Digitalmars-d-learn
Is there a way to make sure a delegate only reads state, without changing it? I tried annotating the delegate as const, but that does not seem to work. ```D void main() { import std.stdio : writeln; auto r = [0,1,2,3]; auto f = delegate() const // Compiles even though we are chang

Re: Read only delegate

2016-04-04 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 4 April 2016 at 08:10:10 UTC, Edwin van Leeuwen wrote: Is there a way to make sure a delegate only reads state, without changing it? I tried annotating the delegate as const, but that does not seem to work. Note that annotating with pure also doesn't help. As a result we can have

Re: Read only delegate

2016-04-04 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 4 April 2016 at 11:32:23 UTC, Rene Zwanenburg wrote: On Monday, 4 April 2016 at 08:10:10 UTC, Edwin van Leeuwen wrote: Is there a way to make sure a delegate only reads state, without changing it? I tried annotating the delegate as const, but that does not seem to work. ``` Yeah t

Re: Read only delegate

2016-04-04 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 4 April 2016 at 11:39:55 UTC, Kagamin wrote: On Monday, 4 April 2016 at 11:32:23 UTC, Rene Zwanenburg wrote: https://issues.dlang.org/show_bug.cgi?id=1983 Bug 1983 is about usage of delegates after creation, restrictions during creation are enforced. AIU, OP wants to have const ch

Re: how to parse a string into a phobos datatype with additional logic

2016-04-07 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 7 April 2016 at 07:45:06 UTC, yawniek wrote: what is the way one is supposed to parse e.g. a double of unixtime (as delived by nginx logs) into a SysTime? currently i'm creating a wrapper struct around SysTime with alias this as: https://gist.github.com/yannick/6caf5a5184beea0c24

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 7 April 2016 at 07:07:40 UTC, Puming wrote: Hi: when I use map with joiner, I found that function in map are called. In the document it says joiner is lazy, so why is the function called? say: int[] mkarray(int a) { writeln("mkarray called!"); return [a * 2]; // just for

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 7 April 2016 at 08:17:38 UTC, Puming wrote: On Thursday, 7 April 2016 at 08:07:12 UTC, Edwin van Leeuwen wrote: OK. Even if it consumes the first two elements, then why does it have to consume them AGAIN when actually used? If the function mkarray has side effects, it could lead

Re: is std.algorithm.joiner lazy?

2016-04-07 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 7 April 2016 at 09:55:56 UTC, Puming wrote: When compiled, I get the error: Error: open path skips field __caches_field_0 source/app.d(19, 36): Error: template instance std.algorithm.iteration.cache!(MapResult!(__lambda1, int[])) error instantiating That seems like a bug to me a

Re: simple range question

2016-04-08 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Friday, 8 April 2016 at 18:27:59 UTC, Laeeth Isharc wrote: suppose I have a forward or random access range. what's the best way to compare each element with the element 4 elements prior to that element? I could map each element to a tuple of the element and the element 4 bars previously an

Re: JSONValue floating and 42

2016-04-19 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 19 April 2016 at 13:44:08 UTC, Andre wrote: -> I need to analyze every value whether it is a floating or an integer? This is the correct option. Something like: double f; if (j["value"].type == JSON_TYPE.INTEGER) f = j["value"].integer.to!float; else f = j["value"].floating; T

Re: DUB and pragma lib - OSX

2016-04-19 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 05:53:28 UTC, Joel wrote: How do I get this C stuff working with DUB? Mind posting your dub configuration file?

Re: ggplotd - curve colour

2016-05-08 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Sunday, 8 May 2016 at 01:50:38 UTC, brocolis wrote: How do I set the color of a curve with ggplotd? Thanks. You can set colours by name: https://github.com/BlackEdder/ggplotd/blob/master/source/ggplotd/colour.d#L20 Alternatively you can pass through the RGB value (see the link above for th

Re: ggplotd - curve colour

2016-05-08 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Sunday, 8 May 2016 at 01:50:38 UTC, brocolis wrote: How do I set the color of a curve with ggplotd? Thanks. Also see the below example on how to merge Colour with an existing range of points using mergeRange: (Copied from http://blackedder.github.io/ggplotd/stat.html) void main() { ///

Re: ggplotd - curve colour

2016-05-08 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 9 May 2016 at 02:29:47 UTC, brocolis wrote: Is this correct usage? auto gg = GGPlotD().put( geomLine( Aes!(typeof(xs), "x", typeof(ysfit), "y", string, "colour")( xs, ysfit, "red") ) ); The output is a blank png file. Full source: import ggplotd.ggplotd; import ggplotd.geom; import

Re: static import (v2.071.0)

2016-05-11 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 11 May 2016 at 14:24:03 UTC, Chris wrote: I was wondering if `static import std.file;` `if (exists(file))` will only import `std.file.exists` or the whole lot of `std.file`? I want to find out what the best strategy for imports is now. I tend to do specified imports, although

Re: Compile Tango for DMD2 - Any instructions how to do it?

2016-05-18 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 18 May 2016 at 16:37:48 UTC, TheDGuy wrote: On Wednesday, 18 May 2016 at 16:13:35 UTC, Seb wrote: May I ask why you need to get tango working? It has been deprecated a long time ago and phobos (the standard library) or alternatively other packages on dub have a look of features :

Re: static member and/or @property ?

2016-05-19 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 19 May 2016 at 15:04:00 UTC, chmike wrote: The only viable solution I found so far is by using distinct member names. In the interface we define name as a property, and in the class we define the static member with another name. Is it possible to avoid the different names ? Can y

Re: static member and/or @property ?

2016-05-19 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 19 May 2016 at 15:12:44 UTC, Edwin van Leeuwen wrote: On Thursday, 19 May 2016 at 15:04:00 UTC, chmike wrote: The only viable solution I found so far is by using distinct member names. In the interface we define name as a property, and in the class we define the static member with

Trying to get type and name at compile time

2016-05-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
Hi all, I am trying to get the type and name of a field at compile time, but can't get the following to work. Anyone any idea of why test is not of the type AliasSeq!(double, "x")? ``` import std.meta : AliasSeq; struct Point { double x; double y; } alias test = AliasSeq!( typeof(__tra

Re: Trying to get type and name at compile time

2016-05-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 15:09:43 UTC, Adam D. Ruppe wrote: On Tuesday, 24 May 2016 at 15:01:33 UTC, Edwin van Leeuwen wrote: // I expected AliasSeq!(double,"x")??? pragma(msg,test); // tuple((double), "x") What Phobos calls AliasSeq is called tuple inside the compiler. They are the same th

Re: Trying to get type and name at compile time

2016-05-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 18:44:45 UTC, ag0aep6g wrote: Seems to be a problem in ApplyLeft: import std.meta: AliasSeq, ApplyLeft; alias addType(T, string name) = AliasSeq!(T, name); alias addTypeInt = ApplyLeft!(addType, int); alias FullyInstantiated = addTypeInt!"foo"; Fails with:

Re: local const functions - bug ?

2016-07-07 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 7 July 2016 at 10:33:39 UTC, Basile B. wrote: this compiles without error: struct Foo { int i; void bar() { void foo() const { i = 1; } foo; } } In this case "const" seems to be a noop. Do you think it's a bug ? Shouldn'

Re: Docs for `Group` type

2016-07-12 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 11:40:48 UTC, Bahman Movaqar wrote: On 07/12/2016 01:01 PM, Mike Parker wrote: Do you have some sample code that shows the error? Yes. I'm working on Stockman[1] a playground to learn D. In file `etl.d`, line 110 [2], if I change the line to auto refInvoice = g

Re: Using external libraries the correct way

2016-07-17 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Sunday, 17 July 2016 at 17:52:59 UTC, solidstate1991 wrote: Up to this day, I have to use them by dragging the source into my project. When I tried to import imageformats, the compiler looks up for the file imageformats.d and fails to finish the program. I'm not using command line for comp

Delegate, scope and associative array

2014-06-02 Thread Edwin van Leeuwen via Digitalmars-d-learn
I'm probably missing something basic, but I am confused by what is going on in the following code. unittest { size_t delegate()[size_t] events; foreach( i; 1..4 ) { events[i] = { return i; }; } writeln( events[1]() ); // This outputs 3 assert( events[1]() == 1 ); } I

Re: Delegate, scope and associative array

2014-06-02 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 2 June 2014 at 23:44:01 UTC, Rene Zwanenburg wrote: On Monday, 2 June 2014 at 20:09:12 UTC, Edwin van Leeuwen wrote: As you may have guessed, a workaround is to copy the iteration variable yourself: unittest { size_t delegate()[size_t] events; foreach(_i; 1..4 ) { au

Re: Delegate, scope and associative array

2014-06-02 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 3 June 2014 at 05:40:44 UTC, Edwin van Leeuwen wrote: On Monday, 2 June 2014 at 23:44:01 UTC, Rene Zwanenburg wrote: On Monday, 2 June 2014 at 20:09:12 UTC, Edwin van Leeuwen wrote: As you may have guessed, a workaround is to copy the iteration variable yourself: unittest { siz

Re: Delegate, scope and associative array

2014-06-03 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 3 June 2014 at 07:00:35 UTC, Ali Çehreli wrote: Here is a workaround: unittest { size_t delegate()[size_t] events; auto makeClosure(size_t i) { return { return i; }; } foreach( i; 1..4 ) { events[i] = makeClosure(i); } assert( events[1]() ==

Re: D JSON (WAT?!)

2014-07-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:42:58 UTC, Pavel wrote: On Thursday, 24 July 2014 at 15:38:06 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:32:29 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote: Ok, let me start with the sample code: import std.stdio;

Re: DUB: link to local library

2014-09-10 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 10 September 2014 at 13:40:16 UTC, rcor wrote: dub.json contains what I think should do the same as above: { "name": "test", "importPaths": ["ext/dallegro5"], "lflags": ["-Lext/dallegro5"] } Does adding: "libs": ["dallegro5"] make a difference? Cheers, Edwin

Re: Recomended cairo bindings

2014-09-15 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 15 September 2014 at 12:11:09 UTC, Paul Z. Barsan wrote: On Sunday, 14 September 2014 at 14:37:05 UTC, Robert burner Schadek wrote: If you look at deimos.cairo you will see that the latest commit was made 2 years ago while cairoD was last updated 6 months ago. I think the latest c

Using return type of a predicate function as a template

2014-10-16 Thread Edwin van Leeuwen via Digitalmars-d-learn
I am trying to implement a groupBy function that groups by the return type of a predicate. Currently I have to define the returntype of the predicate for it to compile. Is there a way to get the return type at compile time and use it. The code: V[K] groupBy( alias func, K, V )( V values ) {

Re: Using return type of a predicate function as a template

2014-10-16 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 16 October 2014 at 08:18:02 UTC, Atila Neves wrote: This works: import std.range; auto groupBy(alias func, R)(R values) if (isInputRange!R) { alias K = typeof(func(values.front)); alias V = ElementType!R[]; V[K] grouped; foreach(value; values) grouped[func(valu

Re: Indivisual Incremental Compalation with dub

2015-08-13 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 13 August 2015 at 05:42:38 UTC, Freddy wrote: I have a file that takes a while to compile with a static interface. Is there any way i can make dub keep the object file of only that file(for faster compilation)? I don't think dub itself can do this, but https://github.com/atilanev

Re: dub and subpackages

2015-08-14 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Friday, 14 August 2015 at 08:06:15 UTC, yawniek wrote: i'm trying to have my own versions of my dependencies as git submodules. whats the correct way of having a chain of packages included from git submodules so that every packages get's only picked once? dub add-local allows you to add

Re: Compiletime Vs Runtime bencmarks

2015-08-17 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 17 August 2015 at 14:43:35 UTC, D_Learner wrote: Hello everyone . I need advice on my first D-project . I have uploaded it at :- Current Results for the pattern="GCAGAGAG" are as below :- BM_Runtime = 366 hnsecs position= 513 BM_Compile-time = 294 hnsecs pos

Re: (De)Serializing interfaces

2015-08-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 24 August 2015 at 09:26:40 UTC, Edwin van Leeuwen wrote: On Saturday, 22 August 2015 at 19:14:16 UTC, nims wrote: Painlessjson indeed does not support interfaces/subclasses at the moment. There was some discussion about it here: https://github.com/BlackEdder/painlessjson/issues/8 ,

Re: (De)Serializing interfaces

2015-08-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Saturday, 22 August 2015 at 19:14:16 UTC, nims wrote: I think interfaces are very powerful and I heavily use them. The only problem I have with them is that serializing/deserializing them to XML or JSON doesn't seem to work. So far I got to try Orange and painlessjson. Using Orange all I go

Re: reading file byLine

2015-09-04 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Friday, 4 September 2015 at 11:50:23 UTC, deed wrote: import std.algorithm, std.range, std.array, std.string, std.stdio, std.conv; int[] arr1 = [1, 2, 30]; //arr1.max.writeln; // Doesn't work, as you say arr1.reduce!max.writeln;// This does. Prints 30. Again using reduce is t

Re: reading file byLine

2015-09-04 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Friday, 4 September 2015 at 12:06:08 UTC, Edwin van Leeuwen wrote: On Friday, 4 September 2015 at 11:50:23 UTC, deed wrote: import std.algorithm, std.range, std.array, std.string, std.stdio, std.conv; int[] arr1 = [1, 2, 30]; //arr1.max.writeln; // Doesn't work, as you say arr1.re

Re: What is "FilterResult" type?

2015-09-08 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 8 September 2015 at 11:08:59 UTC, Bahman Movaqar wrote: On Tuesday, 8 September 2015 at 10:08:03 UTC, cym13 wrote: Filter is a template and returns a FilterResult range which is used to lazily compute the result. This behaviour is the same for map and the majority of functions in st

Re: Speeding up text file parser (BLAST tabular format)

2015-09-14 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 14 September 2015 at 12:30:21 UTC, Fredrik Boulund wrote: Hi, Using a small test file (~550 MB) on my machine (2x Xeon(R) CPU E5-2670 with RAID6 SAS disks and 192GB of RAM), the D version runs in about 20 seconds and the Python version less than 16 seconds. I've repeated runs at le

Re: Speeding up text file parser (BLAST tabular format)

2015-09-14 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 14 September 2015 at 12:50:03 UTC, Fredrik Boulund wrote: On Monday, 14 September 2015 at 12:44:22 UTC, Edwin van Leeuwen wrote: Sounds like this program is actually IO bound. In that case I would not expect a really expect an improvement by using D. What is the CPU usage like when y

Re: Speeding up text file parser (BLAST tabular format)

2015-09-14 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 14 September 2015 at 14:54:34 UTC, Fredrik Boulund wrote: On Monday, 14 September 2015 at 14:40:29 UTC, H. S. Teoh wrote: I agree with you on that. I used Python's cProfile module to find the performance bottleneck in the Python version I posted, and shaved off 8-10 seconds of runtim

Re: reading file byLine

2015-09-18 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Friday, 18 September 2015 at 10:26:46 UTC, Namal wrote: Hello guys, is there a nice functional way to read the file which is like 1,2,3,4,5,6 2,3,4,5,6,7 8,9,0,9,2,3 line by line, split numbers and remove each ',' convert it to int and save in a matrix int[][] arr? Not tested, but I thin

Re: reading file byLine

2015-09-18 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Friday, 18 September 2015 at 10:48:25 UTC, Namal wrote: On Friday, 18 September 2015 at 10:34:41 UTC, Edwin van Leeuwen wrote: On Friday, 18 September 2015 at 10:26:46 UTC, Namal wrote: Hello guys, is there a nice functional way to read the file which is like 1,2,3,4,5,6 2,3,4,5,6,7 8,9,0

Re: reading file byLine

2015-09-18 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Friday, 18 September 2015 at 11:11:51 UTC, Namal wrote: compiles but crashes For me it works fine. You probably have extra spaces or something in your file. It would help if you posted the error message you get when running the program.

Re: reading file byLine

2015-09-18 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Friday, 18 September 2015 at 12:28:29 UTC, Namal wrote: So do I understand it right: does => in map! indicates a lambda function? Yes exactly. There are a number of ways you can define a lambda function in D. For example if the function is multiline I often use: (l) { ...; // do somet

Re: Dub package with C code

2015-09-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 24 September 2015 at 06:21:02 UTC, Sebastiaan Koppe wrote: Because I want to focus on the product I am building right now, not on side-projects. You could try including the c source in your repo and add preBuildCommands to the dub config which builds the static library. Alternati

Re: ORM libraries for D

2015-09-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 24 September 2015 at 13:24:14 UTC, Rikki Cattermole wrote: Dvorm is more or less feature complete :) I am the author of it, but unless issues come up I do not intend to continue working upon it. You could consider bumping it up to version 1.0.0 to highlight this.

Re: Command Line Utility Library

2016-08-16 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 15 August 2016 at 07:29:58 UTC, UDW wrote: Hi, I would like some options for a library, preferably json configurable, that helps with command line tool development. Doesn't have to be in D specifically. I am using: http://code.dlang.org/packages/docopt It's not really json conf

Re: Command Line Utility Library

2016-08-16 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 16 August 2016 at 13:32:26 UTC, Jacob Carlborg wrote: On 2016-08-16 11:37, Seb wrote: Manual work? O_o Just open code.dlang.org and either hit CTRL-F or use the search bar (Martin added elastic search two months ago) as the packages usually have a very low PageRank. It's a bit

Re: Serialize/Deserialize Tuple

2016-08-19 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Friday, 19 August 2016 at 09:55:32 UTC, Steve Biedermann wrote: I'm trying to send data over the network. On the receiving side, I need a tuple of the sent values. Is there any way to achieve this? Depends on the format the data is send in. There are a number of serialization/deserializati

Re: Checking all elements are unique.

2016-08-31 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 31 August 2016 at 07:40:39 UTC, Dorian Haglund wrote: Hello, I have an array of objects of class C which contain a id member. I want to figure out if all the id members are unique using functional primitives. For example, if I have: class C { int id; } and an array of C 'Cs'

Re: Draw math formulas with ggplotd

2016-09-17 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Saturday, 17 September 2016 at 02:41:15 UTC, brocolis wrote: How do I draw math formulas programmatically? I want to do on screen what latex does on .pdf. And I want to draw a math formula in the image generated with ggplotd. You can't at the moment. Parsing latex equations is not a trivi

Re: Draw math formulas with ggplotd

2016-09-17 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Saturday, 17 September 2016 at 09:56:09 UTC, Edwin van Leeuwen wrote: On Saturday, 17 September 2016 at 02:41:15 UTC, brocolis wrote: How do I draw math formulas programmatically? I want to do on screen what latex does on .pdf. And I want to draw a math formula in the image generated with

Re: Draw math formulas with ggplotd

2016-09-17 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Saturday, 17 September 2016 at 11:22:04 UTC, John Colvin wrote: On Saturday, 17 September 2016 at 02:41:15 UTC, brocolis wrote: How do I draw math formulas programmatically? I want to do on screen what latex does on .pdf. And I want to draw a math formula in the image generated with ggplot

Re: Draw math formulas with ggplotd

2016-09-17 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Saturday, 17 September 2016 at 11:57:17 UTC, John Colvin wrote: On Saturday, 17 September 2016 at 11:45:07 UTC, Edwin van Leeuwen wrote: But I assumed he meant adding the formula onto the plot. Hah, yes, I should have read the question better. Rereading the question I am actually not sure

Re: polar coordinates with ggplotd

2016-09-19 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Sunday, 18 September 2016 at 22:13:35 UTC, brocolis wrote: Found an error in ys line. Thanks. Does that mean you solved it? Currently there is no special support for other coordinate systems, but I recently added Guides for x/y coordinates which should make this relatively straightforward

Re: From Python to Dlang

2016-10-18 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 18 October 2016 at 12:03:54 UTC, Alfred Newman wrote: Hello and greetings, I'm a brand new D developer coming from Python. So, can you pls guys suggest me any resource like "D for a Python Developer" or so ? BTW, I just ordered the "D Programming Language" book from AA. Cheers

Re: Avoiding GC

2016-10-26 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 08:18:07 UTC, hardreset wrote: Is there a page somewhere on how to program D without using the GC? How do I allocate / free structs / classes on the heap manually? New would be GCed memeory wouldnt it? Delete is being depreciated? thanks. There is the follow

Re: Combining "chunkBy" and "until" algorithms

2016-11-04 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Friday, 4 November 2016 at 08:04:12 UTC, Jacob Carlborg wrote: Currently I'm using a standard for loop iterating over the lines. I'm always looking at the current line and the next line. When the current line is the standard pattern and the next line is is not, I do a separate loop until I s

Re: problem with isnan

2016-11-11 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 10 November 2016 at 23:45:01 UTC, Charles Hixson wrote: you might try using std.math.isNaN instead and see what it does. It was default initialized by the class instance: classCell ... floatcurActivation; ... The this method doesn't have any mention of a few variables t

Re: Compiling and linking libraries

2016-11-16 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 16 November 2016 at 14:27:41 UTC, Darren wrote: Hey all, This is a very beginner problem, but not one I know how to do on my own. Could anyone give a step-by-step guide on how to compile libraries, and then use them in my project with DUB? If you are happy to use dub I would j

Re: drepl fails because of missing lib linenoise

2016-12-08 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 8 December 2016 at 12:31:01 UTC, Nordlöw wrote: drepl fails to build as https://github.com/drepl/drepl/issues/58 Any ideas why? Looks like you don't have liblinenoise installed. Some basic notes on how to install on linux/macosx can be found here: https://github.com/BlackEdder