Re: Improving dot product for standard multidimensional D arrays

2020-03-03 Thread maarten van damme via Digitalmars-d-learn
it is difficult to write an efficient matrix matrix multiplication in any language. If you want a fair comparison, implement your naive method in python and compare those timings. Op di 3 mrt. 2020 om 04:20 schreef 9il via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com>: > On Sunday, 1 M

Re: D is Multiplatform[DUVIDA]

2017-09-08 Thread maarten van damme via Digitalmars-d-learn
It's a compiled language, it'll behave like c++. 2017-09-08 7:13 GMT+02:00 dark777 via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com>: > On Friday, 8 September 2017 at 03:56:25 UTC, rikki cattermole wrote: > >> On 08/09/2017 3:08 AM, dark777 wrote: >> >>> On Friday, 8 September 2017 at

Re: very odd directx 11 error

2017-08-24 Thread maarten van damme via Digitalmars-d-learn
17-08-24 17:26 GMT+02:00 maarten van damme : > I should probably add that the error is a hresult, being 0 when it works > but -2005270527 when it fails. > > 2017-08-24 17:24 GMT+02:00 maarten van damme : > >> Hi all. >> >> This works (dub --arch=x86_mscoff)

Re: very odd directx 11 error

2017-08-24 Thread maarten van damme via Digitalmars-d-learn
I should probably add that the error is a hresult, being 0 when it works but -2005270527 when it fails. 2017-08-24 17:24 GMT+02:00 maarten van damme : > Hi all. > > This works (dub --arch=x86_mscoff) http://dpaste.com/1XCJEX7 but this > fails : http://dpaste.com/1C7WMB7 . > &g

very odd directx 11 error

2017-08-24 Thread maarten van damme via Digitalmars-d-learn
Hi all. This works (dub --arch=x86_mscoff) http://dpaste.com/1XCJEX7 but this fails : http://dpaste.com/1C7WMB7 . Notice that all I've done is manually inlined init3d... You can compile this with the following dub.json http://dpaste.com/2QBQFSX Any help would be appreciated, it make absolutely

Re: How to get uniq to return an array?

2017-07-04 Thread maarten van damme via Digitalmars-d-learn
have you tried std.range's .array? 2017-07-04 13:00 GMT+02:00 PumpkinCake via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com>: > I'm trying to strip repeated values out of an int array using uniq. It's > returning a UniqResult which can't be accessed like an array... how can I > get it t

Re: Neural Networks / ML Libraries for D

2016-10-25 Thread maarten van damme via Digitalmars-d-learn
There is mir https://github.com/libmir/mir which is geared towards machine learning, I don't know if it has anything about neural networks, I've yet to use it. If you're only interested in neural networks, I've used FANN (a C library) together with D and it worked very well. 2016-10-25 13:17 GMT+0

Re: store template value

2015-08-02 Thread maarten van damme via Digitalmars-d-learn
Oh, neat. This saves the day :) 2015-08-01 23:22 GMT+02:00 Ali Çehreli : > On 08/01/2015 08:37 AM, maarten van damme via Digitalmars-d-learn wrote: > >> I have a class that creates a task in it's constructor. How do I store >> this >> created task as one of it'

Re: store template value

2015-08-01 Thread maarten van damme via Digitalmars-d-learn
But it's std.parallelism's task... And how can I use get!T if I don't know the type of the task? 2015-08-01 19:02 GMT+02:00 Adam D. Ruppe via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com>: > On Saturday, 1 August 2015 at 16:41:54 UTC, maarten van damme wrote: &

Re: store template value

2015-08-01 Thread maarten van damme via Digitalmars-d-learn
almars-d-learn@puremagic.com>: > On Saturday, 1 August 2015 at 15:37:46 UTC, maarten van damme wrote: > >> I have a class that creates a task in it's constructor. How do I store >> this created task as one of it's value members and later on call >> .yieldForce()?

store template value

2015-08-01 Thread maarten van damme via Digitalmars-d-learn
I have a class that creates a task in it's constructor. How do I store this created task as one of it's value members and later on call .yieldForce()?

Re: How to use core.thread.Thread

2015-07-16 Thread maarten van damme via Digitalmars-d-learn
/ders/d.en/ 2015-07-16 11:24 GMT+02:00 aki via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com>: > On Thursday, 16 July 2015 at 08:21:26 UTC, maarten van damme wrote: > >> Have you checked out std.parallelism and std.concurrency? >> > > I know std.concurre

Re: How to use core.thread.Thread

2015-07-16 Thread maarten van damme via Digitalmars-d-learn
Have you checked out std.parallelism and std.concurrency? 2015-07-16 9:57 GMT+02:00 aki via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com>: > I can't resolve the compile errors: > > import core.thread; > class DerivedThread : Thread { > int count = 0; > this() { >

Re: Beginner ?. Why does D suggest to learn java

2014-10-16 Thread maarten van damme via Digitalmars-d-learn
While d can be complex, there's nothing preventing you from starting out simple and not using all features at first. I don't understand why it's not suitable for a beginner if you use this approach... 2014-10-17 6:51 GMT+02:00 via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com>: > On Fri

Re: D with no druntime

2014-08-21 Thread maarten van damme via Digitalmars-d-learn
There were 2 talks about bare metal D this year at the D conference. The first one is about someone able to use D on microcontrollers with a few k ram.: https://www.youtube.com/watch?v=o5m0m_ZG9e8 The second one is about someone trying to strip almost everything out and see what works: https://ww

Re: Command Line Application in D

2014-08-04 Thread maarten van damme via Digitalmars-d-learn
I am a little bit confused as to what you want. There is a command line example at dlang.org, and there exists a program (rdmd) that compiles several D files and runs them. http://dlang.org/rdmd.html 2014-08-04 23:20 GMT+02:00 TJB via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com>: > I

Re: std.algorithm range violation

2014-05-28 Thread maarten van damme via Digitalmars-d-learn
wow. senpai, teach me what I did wrong... 2014-05-28 13:21 GMT+02:00 bearophile via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com>: > maarten van damme: > > > writeln(providor_symbol_map.keys.sort!((x,y)=>providor_ >> symbol_map[x].length>=providor_sym

Re: std.algorithm range violation

2014-05-28 Thread maarten van damme via Digitalmars-d-learn
nderer via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com>: > On Wednesday, 28 May 2014 at 10:10:41 UTC, maarten van damme via > > Digitalmars-d-learn wrote: > >> an anyone explain me what I'm doing wrong here : >> >> [code] >> dstring[][dstring]

std.algorithm range violation

2014-05-28 Thread maarten van damme via Digitalmars-d-learn
an anyone explain me what I'm doing wrong here : [code] dstring[][dstring] providor_symbol_map; ... writeln(providor_symbol_map.keys.sort!((x,y)=>providor_symbol_map[x].length>=providor_symbol_map[y].length)); [/code] output: core.exception.RangeError@std.algorithm(9429): Range violation

Re: Newbie questions. Which Compiler to start with? Real Time behaviour? Has anyone converted CImg yet?

2013-09-01 Thread maarten van damme
1) afaik you can't cross compile to arm with dmd. I know it's possible with gdc. 2) There are people who successfully use d without gc. I think andrei posted a stub gc that throws an exception every time the garbage collector is tried to get used. You can't use whole phobos (yet) without gc. 2013

Re: A little of coordination for Rosettacode

2013-08-30 Thread maarten van damme
the entry : http://rosettacode.org/wiki/File_IO is wrong because as stated by the asignment : "In this task, the job is to create a file called "output.txt", and place in it the contents of the file "input.txt", *via an intermediate variable.**"* * * there is no intermediate variable; I don't know

Re: std.algorithm's remove

2013-08-24 Thread maarten van damme
I'm not sure if it really is my place to criticize design decisions of a language written by people that devoted their career to computer science while I have only read some books out of boredom :) 2013/8/25 bearophile > maarten van damme: > > > But remove doesn't

Re: std.algorithm's remove

2013-08-24 Thread maarten van damme
> > (apart from reading the documentation on every single >> trivial function in the std library?) >> > > Before using every function from the standard library you have to read its > documentation, this is sure. You can not assume its behavour to be exactly > the same you hope it to have. This is

Re: std.algorithm's remove

2013-08-24 Thread maarten van damme
Correction, I could really use remove to begin with, only have to dup the range. Still convinced that the remove behaviour is counterintuitive but I assume good reasons exist... 2013/8/25 maarten van damme > But remove doesn't truly remove from the source range because the length

Re: std.algorithm's remove

2013-08-24 Thread maarten van damme
of the time debugging. This as opposed to using racket where the time spent is 15 minutes but after that everything works great (while my racket experience is limited to playing around with it for 2 weeks now and then). 2013/8/25 Brad Anderson > On Sunday, 25 August 2013 at 02:24:30 UTC, ma

std.algorithm's remove

2013-08-24 Thread maarten van damme
hello, I'm a hobyist-programmer and around where I live there's a group of haskell fanatics. They posted solutions to a recent programming challenge which I find to be a bit ugly. For fun I wanted to implement it in d and a rough version (not correct yet, this was written/hacked in 5 minutes after

Re: randomShuffle

2013-06-03 Thread maarten van damme
How about using std.random.randomSample? 2013/6/3 Yann > Hey, > > I am trying to generate an array of 10 unique (!) random numbers from 1 to > 1000 each (for example). The best I could come up with is: > > auto arr = iota(1, 1000).array; > randomShuffle(arr); > return arr.take(10).array.sort; >

Re: how to avoid memory leaking

2013-05-14 Thread maarten van damme
So now pgen.d works (without simpledisplay version an reusing trueimage). The simpledisplay version still has problems, but I'll try (manually (de)allocating)/(reusing) the data 2013/5/14 Adam D. Ruppe > On Monday, 13 May 2013 at 21:28:34 UTC, maarten van damme wrote: > >>

Re: how to avoid memory leaking

2013-05-13 Thread maarten van damme
I'll check every uint occurance, thank you. I'm on windows so I won't get the "maximum number of clients" error you talk about. The loop I used inside main was : "while(true){ curtrans=generateTransformationMatrix(); for(int y=0;y > On Friday, 10 May 2013 at 23:1

Re: Disgusted

2013-05-13 Thread maarten van damme
If you define intelligence as the ability to learn computer languages, I'd have to disagree with you. No reason to be disgusted, just curious. Why on earth would you spend your time doing that? 2013/5/13 D-Ratiseur > On Monday, 13 May 2013 at 00:21:06 UTC, John Colvin wrote: > >> On Monday, 13

Re: how to avoid memory leaking

2013-05-13 Thread maarten van damme
But seeing as the memory only starts growing when I put the png line in, and that I keep deleting the old class and replacing it for a new instance, shouldn't the gc clean up everything as nothing can still be referencing to that data? I am working on windows, on linux my original code segfaulted,

Re: how to avoid memory leaking

2013-05-12 Thread maarten van damme
using this? The reduced loop that only generates images is here : TrueColorImage i= new TrueColorImage(width,height); PNG* png; double[][4] curtrans; while(true){ curtrans=generateTransformationMatrix(); for(int y=0;y > Am 12.05.2013 21:05, schrieb maarten van damme: > >> This is rid

Re: how to avoid memory leaking

2013-05-12 Thread maarten van damme
This is ridiculous. Your solution appears to keep the memory somewhat constant around 20mb-28mb untill it suddenly runs out of memory. Literally out of nowhere. I have no idea what's causing everything, so I decided to get rid of the window altogether and to try saving the images instead of displa

Re: how to avoid memory leaking

2013-05-12 Thread maarten van damme
(the class allocating the buffer) is getting called everytime... Does this mean that a destructor getting called still is no garantee that all data is getting free'd? 2013/5/12 Benjamin Thaut > Am 11.05.2013 01:18, schrieb maarten van damme: > > I'm trying to generate ima

how to avoid memory leaking

2013-05-10 Thread maarten van damme
I'm trying to generate images and after displaying them I want to save them to a png file. I use parallelism to generate them asynchronously with the gui-thread to avoid blocking (don't know if this is really relevant). If I add a single line in the method where I generate the image that creates a

Re: variable x cannot be read at compile time (ctfe)

2012-12-18 Thread maarten van damme
My only assumption is that -version=runtime doesn't utilize ctfe and the other does. The rest is simple timing on both linux and windows and ctfe is way slower... 2012/12/18 bearophile : > maarten van damme: > >> How can this be? > > > Maybe there are some mistakes in

Re: variable x cannot be read at compile time (ctfe)

2012-12-17 Thread maarten van damme
How do I make dmd output asm? I wrote a simple test and for a simple int[] array it was 2,5 times slower. 2012/12/17 bearophile : > maarten van damme: > > >> it's odd that the resulting arraylist is slower to access at runtime >> then the arraylist generated at runtim

Re: variable x cannot be read at compile time (ctfe)

2012-12-17 Thread maarten van damme
Thanks, I'm really happy it works now. it's odd that the resulting arraylist is slower to access at runtime then the arraylist generated at runtime... Is there a reason for this? Should I open bugreports for your testcases? 2012/12/17 bearophile : >> I think it's a problem of nested delegates at

variable x cannot be read at compile time (ctfe)

2012-12-17 Thread maarten van damme
I finally got around trying to finish my sudoksolver and I'm pretty happy with the result, except one little piece that screams for ctfe but I never seem to get it working. I always get "variable x cannot be read at compile time" in this method : auto bitsetToRange(in SudokuCell x) { return bo

Re: DLL Injection

2012-12-03 Thread maarten van damme
Yes, that was the problem :p I have no idea about mcvr71, maybe because of std.process but that isn't that huge a concern

Re: DLL Injection

2012-12-03 Thread maarten van damme
Strangely, the main in my dll is getting executed multiple times and msvcr71.dll gets injected too. Is this normal? 2012/12/3 s0beit : > On Sunday, 2 December 2012 at 22:30:56 UTC, maarten van damme wrote: >> >> Thanks, interesting blog :) >> >> 2012/12/2 s0beit : >

Re: telnet and D

2012-11-29 Thread maarten van damme
> vibe.d is very modular, just import what you need. > I hate to push it, but it has very good documentation and examples. > > Its designed for web apps, but it makes a nice little web library as well. > > import vibe.vibe; > > void main() > { > auto client = new HttpClient; > client.connec

Re: telnet and D

2012-11-27 Thread maarten van damme
> IIRC, telnet is simple, so it shouldn't be too difficult.. Turns out it indeed was simple. My option negotiation had a bug :D my (primitive) telnet client works now :)

Re: telnet and D

2012-11-27 Thread maarten van damme
Haven't looked at vibe.d yet because it looked more like a library for writing web apps and normal sockets should be enough. Didn't know about Tango, I'll try deciphering the original d1 module.

Re: getters and setters not an lvalue

2012-10-31 Thread maarten van damme
Ok, makes sense now :) 2012/10/31 monarch_dodra : > On Wednesday, 31 October 2012 at 12:46:12 UTC, maarten van damme wrote: >> >> In my current code I'd like to do something ala: >> >> void main(){ >> getsettest test=new getsettest(

Re: getters and setters not an lvalue

2012-10-31 Thread maarten van damme
Ok, looking forward to the fix :) Btw, I have a foreach loop and in that foreach loop I want to decide if the current element can stay and if not, I want to remove it. If removing it yields an empty range in the foreach loop, it crashes. What's the sane way to do this?

getters and setters not an lvalue

2012-10-31 Thread maarten van damme
In my current code I'd like to do something ala: void main(){ getsettest test=new getsettest(); test.value+=1; } class getsettest{ int myvalue; this(){ } @property{ int valu

Re: bigger then size_t

2012-10-09 Thread maarten van damme
Another quick question. When I know an array is going to have an length smaller then 255, can I use bytes as index or do I have to use size_t to make it portable across 64 bit platforms?

Re: bigger then size_t

2012-10-09 Thread maarten van damme
Ok, that solves it. Thank you.

Re: Sudoku Py / C++11 / D?

2012-08-25 Thread maarten van damme
> > Congratulations, you have found a compiler bug. I have found > maybe one hundred of those. Please minimize the code and submit > it to Bugzilla :-) > Oh, but try playing around with static and dynamic arrays. You'll be able to find plenty more :p By changing both squareWidth and squareHeight

Re: Sudoku Py / C++11 / D?

2012-08-25 Thread maarten van damme
Ok, thank you very much with your help :)

Re: Sudoku Py / C++11 / D?

2012-08-25 Thread maarten van damme
Ok, I'll try with Array!bool instead of bool. I now renamed a few things, added a few extra checks and generalized bearophiles modifications. Now the only thing keeping it from solving 25 x 25 size sudoku's is the way I input numbers :) However, I now have a very strange issue. Compiling with dmd

Re: Sudoku Py / C++11 / D?

2012-08-25 Thread maarten van damme
While trying to use Array!bool I noticed this: import std.container; void main(){ Array!bool test; test[0]=false; } gives an assertion failure without any information. Also, why on earth can't I instantiate array!bool with a given length?

Re: Sudoku Py / C++11 / D?

2012-08-25 Thread maarten van damme
The puzzle unflipped is extra hard as the solution to the first row is 987 654 321. Come to think of it, one could add a new function "flip" that mutates the sudoku according to well known rules and maybe something like unflip for when the sudoku was finnished. New techniques could certainly be ad

Re: Sudoku Py / C++11 / D?

2012-08-24 Thread maarten van damme
2012/8/25 Timon Gehr : > On 08/24/2012 09:32 PM, maarten van damme wrote: >> >> I've distiled what I understood from your source and the resulting >> executable managed to solve the impossible one in 27 seconds while >> your source takes 41 seconds. >> >

Re: Sudoku Py / C++11 / D?

2012-08-24 Thread maarten van damme
and everythingPossible should also be changed to something ala 2 ^(side) -1

Re: Sudoku Py / C++11 / D?

2012-08-24 Thread maarten van damme
> Some suggestions about the code: Thank you very much for your criticism, there are indeed a lot of points where I have to improve on. > - Put a space before and after operators, after a commas and semicolon, > around "..", etc. > - Compile with "-wi -property"; > - Try to add pure/const/nothrow/

Re: Sudoku Py / C++11 / D?

2012-08-24 Thread maarten van damme
> I'm unsure if searching for the field with the least possibilities was > a smart move because now I have to carry that "taken" array through > all my functions and optimize has to check the whole sudoku instead of > a slice. (come to think of it, taken should've been named occupied) I take that

Re: Sudoku Py / C++11 / D?

2012-08-24 Thread maarten van damme
Thank you very much. I changed line 119 to an explicit cast to int and removed an unneeded cast at line 63. It now happily compiles with 64bit mode : http://dpaste.dzfl.pl/63666f07. It's kind off odd though that compiling with -inline seems to slow it a bit down. I'm unsure if searching for the fi

Re: Sudoku Py / C++11 / D?

2012-08-24 Thread maarten van damme
es fail to compile on dpaste, I have no idea why. It does compile on my machine though... http://dpaste.dzfl.pl/8a2aef5b 2012/8/21, Timon Gehr : > On 08/21/2012 05:52 PM, maarten van damme wrote: >> > On 08/20/2012 11:49 PM, Timon Gehr wrote:> On 08/20/2012 10:43 PM, > maarten van

Re: Sudoku Py / C++11 / D?

2012-08-21 Thread maarten van damme
2012/8/17, Chris Cain : > > Gonna chime in a bit here: > > There's a lot of factors at play when deciding to use shorts vs > bytes vs native-sized ints. The best way to decide is to time all > of them and see which works best overall. > > With caching on a larger problem, I'd guess that the smaller

Re: Sudoku Py / C++11 / D?

2012-08-19 Thread maarten van damme
> Depends. Do you plan on doing more than brute force? Having it > bulk copy them may not be that bad if it's all in one place, and > if you do it like that you have all the combinations that carry > forward to the next level and if you back out it undoes them all > automatically. > No, I think

Re: Sudoku Py / C++11 / D?

2012-08-19 Thread maarten van damme
I'm using a static array. I'm hesitating though if I should store possibilities in a precalculated array or calculate them in-place. If i precalculate the possibilities i'd have to copy them over and over so i don't know if it's smart. Going even further I could even store a filled-in value as an

Re: Sudoku Py / C++11 / D?

2012-08-19 Thread maarten van damme
The infinite loop was my mistake. I was looking at your outer while loop but because you use exceptions instead of return values it indeed throws an exception, my bad :) By replacing ref by const ref my program slowed down (looked over a period of 10_000 runs). Not considerably but noticeable. Com

Re: Sudoku Py / C++11 / D?

2012-08-19 Thread maarten van damme
my code is located at http://dpaste.dzfl.pl/93cd5f45 2012/8/19, maarten van damme : > Great, i tried to get rid of the dynamic array "possibilities" by > representing it using a static array of bools. This approach made it 4 > times faster :) > > When i have a solid wif

Re: Sudoku Py / C++11 / D?

2012-08-19 Thread maarten van damme
Great, i tried to get rid of the dynamic array "possibilities" by representing it using a static array of bools. This approach made it 4 times faster :) When i have a solid wifi connection I'm going to install dmd 2.60 to compile timon's code. In the meantime I've started beautifying the source so

Re: Sudoku Py / C++11 / D?

2012-08-16 Thread maarten van damme
e way more efficient. (although compilation is failing here, I'm running dmd 2.059 and it gives "can't stride on chunks!(short)) would using short or bytes increase performance compared to integers? if so, why did you use shorts instead of bytes? 2012/8/17, Timon Gehr : > On 08/16/

Re: Sudoku Py / C++11 / D?

2012-08-16 Thread maarten van damme
> This is because your specific solution is slow. > > Mine takes <20ms on the 'hard' puzzle and ~13s on the impossible one. > (~2.4 GHZ intel x86_64 machine, with gdmd -O -release -inline -noboundscheck.) > There is a constant factor between those two solutions. I've compiled it using dmd on my la

Re: Sudoku Py / C++11 / D?

2012-08-16 Thread maarten van damme
I've now ran in something odd. Using a slight variant from my program on dpaste (can't upload modified version atm but changes are minimal) it takes 0.6 seconds to solve the hard puzzle the python version took 180 seconds for. Yet on the last puzzle, the impossible one, python takes 1800 seconds to

Re: Sudoku Py / C++11 / D?

2012-08-15 Thread maarten van damme
solving sudoku's well too : http://dpaste.dzfl.pl/903e34b5 I have one question though, how can you make it find all possible solutions? 2012/8/16, Era Scarecrow : > On Thursday, 16 August 2012 at 01:05:20 UTC, Era Scarecrow wrote: >> So far having it running it's found over 23k+ combinations >> af

Re: sorting failed error

2012-07-31 Thread maarten van damme
I now tried to bring it to the next level, using concurrency to bread a couple of populations and make the best solutions migrate between them. But, to use concurrency in D, one has to continually cast between immutable, cast immutable away, Not only that, casting away from immutable (or too,

Re: sorting failed error

2012-07-30 Thread maarten van damme
2012/7/31 Timon Gehr : > I realize that the code is just for fun, but I have some comments: > > - don't .dup stuff just in order to index directly. it never has > any effect other than performance degradation. (this could be a > compiler warning) > > - crossOver and mutate mutate their parameters i

Re: sorting failed error

2012-07-30 Thread maarten van damme
monarch_dodra, I'm not trying to order cities, I'm trying to filter out duplicate's in my dna chromosomes and "==" isn't working on structs that encapsulates dynamic arrays. And I can compare elements without defining opCmp. I've written a function that calculates the distance travelled when going

Re: sorting failed error

2012-07-30 Thread maarten van damme
Great, with that workaround everything works correctly now. I can finally start playing around with my salesman's dna :p There is one little problem left, the comparing problem. I can't really define an opcmp because a city isn't smaller or bigger than another city, it's simply another city. I tr

Re: sorting failed error

2012-07-30 Thread maarten van damme
2012/7/30 bearophile : > maarten van damme: > > >> I really dislike contracts, they kind off blow your function up while >> adding not that much. I'll add some unit tests. > > > They make your programs more robust. Contracts are used to spot bugs in your > cod

Re: sorting failed error

2012-07-30 Thread maarten van damme
About float not beeing deterministic, would this behavior also exist when I use doubles? I've changed everything to use doubles now and the same error comes up. My sorting function used < so I guess it can never return on (a,b) when (b,a) was true. But on the other hand, it can return false twice.

Re: sorting failed error

2012-07-30 Thread maarten van damme
it is guaranteed to never be 0 because it always contains all cities so it will always travel something unless there are no cities or when all cities are in the same place (in which case the task to solve is senseless). I'll create an array containing all finesses and try sorting using that. And

Re: sorting failed error

2012-07-30 Thread maarten van damme
My cmp is : bool fitnessCompare(chromosome first,chromosome second){ return fitness(first)>fitness(second); } float fitness(chromosome victim){ city[] cities=victim.dna; //we need to start from home and return to home cities=city(0,0) ~ cities;

sorting failed error

2012-07-30 Thread maarten van damme
For fun I started implementing a program that uses genetics algorithm's to solve the travelling salesman problem. I want to sort an array of chromosome structures according to their fitness. I now get the error: core.exception.AssertError@C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm. d(671

Re: an enum inside another enum

2012-07-26 Thread maarten van damme
Such a shame that enums do not allow mixins to be made. This (mixin(EnumInh!First)) would've been an imho way cleaner solution then declaring your own kind off enum and doing template magic on that. I still have some problems with Simen's code (the first one, haven't yet experimented with enumerat

an enum inside another enum

2012-07-26 Thread maarten van damme
Hi, would the response to this question : http://stackoverflow.com/questions/757684/enum-inheritance be the same for D? I have these two enums: enum first : string{ a="a", b="b" } enum second : string{ a=first.a, b=first.b, c="c" } Is there a way to make this cleaner? I don't mind having so

Re: getting to know dmd and druntime

2012-07-23 Thread maarten van damme
2012/7/23 Sean Kelly : > On Jul 23, 2012, at 3:53 AM, maarten van damme wrote: > >> Got some more information here : http://wiki.osdev.org/D_Bare_Bones >> >> Any way to do this with dmd? When compiling with -debuglib=none and >> -defaultlib=none I still get a 31 k

Re: getting to know dmd and druntime

2012-07-23 Thread maarten van damme
I couldn't find anything D-related in the map file. When I compile without -debuglib=none and -defaultlib=none I also get a 31 kb executable with the exact same map file. Does he ignore those flags?

Re: getting to know dmd and druntime

2012-07-23 Thread maarten van damme
Got some more information here : http://wiki.osdev.org/D_Bare_Bones Any way to do this with dmd? When compiling with -debuglib=none and -defaultlib=none I still get a 31 kb executable so druntime still gets linked in.

Re: getting to know dmd and druntime

2012-07-22 Thread maarten van damme
2012/7/22 Nick Sabalausky : > Actually, that's just a clever illusion. Your main() method isn't > really the first thing called, the first thing called is a function in > druntime called dmain (or Dmain or _dmain or something like that, I > forget offhand). This function does all the initial stuff

getting to know dmd and druntime

2012-07-22 Thread maarten van damme
Right now I'm a bit confused. I assume that the garbage collector and some other parts from druntime need startup code. But what gets run first is my main method in the d file I compile. Does this mean that the first call to something in druntime calls that startup code? If not, what does get ran f

how to consume less memory

2012-07-09 Thread maarten van damme
I use a foreach with parallel where I download and process webpages. Needles to say, this can consume a lot of memory at peak times. I've noticed the D garbage collector doesn't return the memory when it isn't needed anymore. Is there any clever way to limit that usage? Currently it consumes 1 gig

Re: bad unary function

2012-07-03 Thread maarten van damme
Ok, everything works great now. thank you maarten

Re: bad unary function

2012-07-03 Thread maarten van damme
Ok, that made sense :) Now I get a variable with the Result type and this isn't castable or convertable to an array of strings, how can I extract the actual result now?

bad unary function

2012-07-03 Thread maarten van damme
I have an array of structs and I've written a function that takes as argument a struct (and an array but this is besides the point) and returns a unique string. I wanted to use map to retrieve a string array of all unique strings from that array. I've used it this way: string [] added=map!("toNam

Re: Concurrency in D

2012-06-28 Thread maarten van damme
yeah, I didn't knew std.parallelism was so easy to use. Speed up was really big for minimal effort.

Re: how to handle shared arrays?

2012-06-22 Thread maarten van damme
Well, maybe idup is a bit better then assumeuniqe. I don't work anymore with that mutable array on the workerthread but using idup is in all cases allowed and cannot cause subtle bugs like me reusing a mutable array that I've casted to immutable and send over to another thread. It's a shame that sh

Re: how to handle shared arrays?

2012-06-21 Thread maarten van damme
Oh thank god, this helps soo much. Now I can finally do away with all those ugly shared casts and variables in my other toy code involving threads. It works like a charm, great.

how to handle shared arrays?

2012-06-21 Thread maarten van damme
I want to have two threads. One parses some content ever half hour and the other continuously parses commands passed from the first thread. When the second thread finished something it should send the results back to the first thread who'll present it to the user. The messages the second thread nee

Re: sorting associative array's keys by values

2012-06-18 Thread maarten van damme
and something I forgot to ask, is it a conscious decision to not print out fired asserts in treads? Normally when an assert fails my whole program crashes and I can see what went wrong. With treads however, it quietly dies.

Re: sorting associative array's keys by values

2012-06-18 Thread maarten van damme
Everything turned out to be problems with \r \n. The treading system worked perfectly (although I still don't understand how one can use immutable and receiveonly).

Re: sorting associative array's keys by values

2012-06-17 Thread maarten van damme
another problem, when I do use shared. My code is int amountTreads = 20; if(upperLimit-lowerLimit

Re: sorting associative array's keys by values

2012-06-17 Thread maarten van damme
Ok, everything worked (nearly perfect). Sometimes the webpage gets completely messed up ("<" changes to d134 or something like that) but the tests handle it rather well. That's why I decided to improve it a bit and use treads. I've always been afraid of d treads because I never really got the gras

Re: sorting associative array's keys by values

2012-06-17 Thread maarten van damme
well, the page I parse is automatically generated and thus allways contains . (if the page completely downloaded which it didn't). The second error I found (my mistake) is that newlines get scrambled up severely when downloading the page causing the markers I try to find to sometimes break down on

Re: sorting associative array's keys by values

2012-06-16 Thread maarten van damme
It should allways contain so it has more then 2 elements and there is a note section that starts with "

  1   2   >