Re: Must I compile on the target architecture?

2015-12-28 Thread FrankLike via Digitalmars-d-learn

On Friday, 25 December 2015 at 12:43:05 UTC, Jakob Jenkov wrote:

Hi, just a quick question:

If I write a program in D and I use Windows for development but 
want it to run on Linux, do I have to copy the source code to 
the target Linux machine and compile it there, to make an 
executable for that machine? What is the standard process for 
cross platform compilation?


GDC is best for cross platform compilation,download it from 
gdcproject.org.


Re: Variable below zero but if statement doesn't grab?

2015-12-28 Thread TheDGuy via Digitalmars-d-learn
Get used to it :) Unfortunately, DMD is not emitting the best 
debug information. The program flow is correct, but the line 
info is not, that's why the execution step will not be 
triggered in the real location of the source code.


The simplest example is this:

import std.stdio;

void foo(int x)
{
if (x > 0)  //step 1, correct
{
writeln("bigger");  //step 2, correct
}
else
{
writeln("lower");   //step 3, wrong
}
}

int main(string[] argv)
{
foo(20);   //breakpoint with step in
return 0;
}

If you really want to confuse the debugger, write some asserts 
or contracts here and there and your program will be impossible 
to debug :)


So, do you have any information if there will be a fix to this? 
It is really hard (at least for me) to work with a language which 
doesn't feature a working debugger...


Re: Variable below zero but if statement doesn't grab?

2015-12-28 Thread jkpl via Digitalmars-d-learn

On Monday, 28 December 2015 at 19:22:00 UTC, jkpl wrote:

On Monday, 28 December 2015 at 18:33:16 UTC, jkpl wrote:

On Monday, 28 December 2015 at 18:12:24 UTC, jkpl wrote:

On Monday, 28 December 2015 at 18:02:53 UTC, jkpl wrote:

On Monday, 28 December 2015 at 15:50:06 UTC, Basile B. wrote:

On Monday, 28 December 2015 at 15:07:08 UTC, jkpl wrote:

On Sunday, 27 December 2015 at 16:00:34 UTC, jkpl wrote:
On Sunday, 27 December 2015 at 15:53:55 UTC, TheDGuy 
wrote:

Any idea what i am doing wrong?
https://www.youtube.com/watch?v=j_VCa-5VeP8


You could post the code also, personnaly I'm always 
almost at 2 meters from my screen, with zoom, so I can't 
read the code...


I work more or less lying on a futon. Desks are so 
cheesy...


Anarchism is comfy...


when I'm tired with the conformism I just let my head go on 
the pillow and I sleep...

(snoring)

Even if I dont't think that you have won:
https://youtu.be/Uj_7kTwRMKE?t=2m35s


https://www.youtube.com/watch?v=g7qx5oYdOEA

tous fashos: juif, chrétien, musulmans,...

Il n'y a bien que les communistes qui ont compris que les 
religions c'est de la merde.


Also, european people should ask themselves why they stick on 
the US culture since 60 years, while actually Russians freed 
Berlin.


One last thing. Tough guy ?

https://www.youtube.com/watch?v=1igvrZ0KosA


I always try to find a link to the scene, in south america:

"And finally I've done what I always done...".

I never find it. It's probably because judgment defaits us:

https://www.youtube.com/watch?v=xNRBajLM8_4

We want to show something, but we're always near, no so far, not 
close to our idea.
It exists but we cant find a reference to the perfect 
representation of the idea...




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

2015-12-28 Thread Gary Willoughby via Digitalmars-d-learn

On Monday, 28 December 2015 at 14:05:42 UTC, Ivan Kazmenko wrote:
1. You can find maximum, then second maximum, then third 
maximum and so on - each in constant memory and linear time.  
So, if performance is somehow not an issue, there is a way to 
do it @nogc but in N^2 operations.


That's perhaps too much of a performance hit.

2. If you output the whole array anyway, you may sort the array 
in place.  A sorted array obeys the heap property, so 
subsequent heap operations will still work.


That's actually a good idea. Sort it first, and it should still 
be balanced and correct. Then iteration is easy!


3. The tricky part is when we want to support parallel 
iteration over the same heap.  If we look closely at one 
iteration of heapsort algorithm, it will perhaps become clear 
how to output values so that the array is a heap between any 
two consecutive output operations.  At the very least, our heap 
struct over the array can just track which part of the array is 
already sorted, and work with it separately.


4. Reading and modifying the heap in parallel at the same time 
does not look possible anyway, so this is as far as we can get.


I'll have to test parallel iteration.




Re: Variable below zero but if statement doesn't grab?

2015-12-28 Thread jkpl via Digitalmars-d-learn

On Monday, 28 December 2015 at 18:33:16 UTC, jkpl wrote:

On Monday, 28 December 2015 at 18:12:24 UTC, jkpl wrote:

On Monday, 28 December 2015 at 18:02:53 UTC, jkpl wrote:

On Monday, 28 December 2015 at 15:50:06 UTC, Basile B. wrote:

On Monday, 28 December 2015 at 15:07:08 UTC, jkpl wrote:

On Sunday, 27 December 2015 at 16:00:34 UTC, jkpl wrote:

On Sunday, 27 December 2015 at 15:53:55 UTC, TheDGuy wrote:

Any idea what i am doing wrong?
https://www.youtube.com/watch?v=j_VCa-5VeP8


You could post the code also, personnaly I'm always almost 
at 2 meters from my screen, with zoom, so I can't read the 
code...


I work more or less lying on a futon. Desks are so cheesy...


Anarchism is comfy...


when I'm tired with the conformism I just let my head go on 
the pillow and I sleep...

(snoring)

Even if I dont't think that you have won:
https://youtu.be/Uj_7kTwRMKE?t=2m35s


https://www.youtube.com/watch?v=g7qx5oYdOEA

tous fashos: juif, chrétien, musulmans,...

Il n'y a bien que les communistes qui ont compris que les 
religions c'est de la merde.


Also, european people should ask themselves why they stick on 
the US culture since 60 years, while actually Russians freed 
Berlin.


One last thing. Tough guy ?

https://www.youtube.com/watch?v=1igvrZ0KosA


Re: Variable below zero but if statement doesn't grab?

2015-12-28 Thread jkpl via Digitalmars-d-learn

On Monday, 28 December 2015 at 18:12:24 UTC, jkpl wrote:

On Monday, 28 December 2015 at 18:02:53 UTC, jkpl wrote:

On Monday, 28 December 2015 at 15:50:06 UTC, Basile B. wrote:

On Monday, 28 December 2015 at 15:07:08 UTC, jkpl wrote:

On Sunday, 27 December 2015 at 16:00:34 UTC, jkpl wrote:

On Sunday, 27 December 2015 at 15:53:55 UTC, TheDGuy wrote:

Any idea what i am doing wrong?
https://www.youtube.com/watch?v=j_VCa-5VeP8


You could post the code also, personnaly I'm always almost 
at 2 meters from my screen, with zoom, so I can't read the 
code...


I work more or less lying on a futon. Desks are so cheesy...


Anarchism is comfy...


when I'm tired with the conformism I just let my head go on 
the pillow and I sleep...

(snoring)

Even if I dont't think that you have won:
https://youtu.be/Uj_7kTwRMKE?t=2m35s


https://www.youtube.com/watch?v=g7qx5oYdOEA

tous fashos: juif, chrétien, musulmans,...

Il n'y a bien que les communistes qui ont compris que les 
religions c'est de la merde.


Also, european people should ask themselves why they stick on the 
US culture since 60 years, while actually Russians freed Berlin.


Re: Variable below zero but if statement doesn't grab?

2015-12-28 Thread jkpl via Digitalmars-d-learn

On Monday, 28 December 2015 at 18:02:53 UTC, jkpl wrote:

On Monday, 28 December 2015 at 15:50:06 UTC, Basile B. wrote:

On Monday, 28 December 2015 at 15:07:08 UTC, jkpl wrote:

On Sunday, 27 December 2015 at 16:00:34 UTC, jkpl wrote:

On Sunday, 27 December 2015 at 15:53:55 UTC, TheDGuy wrote:

Any idea what i am doing wrong?
https://www.youtube.com/watch?v=j_VCa-5VeP8


You could post the code also, personnaly I'm always almost 
at 2 meters from my screen, with zoom, so I can't read the 
code...


I work more or less lying on a futon. Desks are so cheesy...


Anarchism is comfy...


when I'm tired with the conformism I just let my head go on the 
pillow and I sleep...

(snoring)

Even if I dont't think that you have won:
https://youtu.be/Uj_7kTwRMKE?t=2m35s


https://www.youtube.com/watch?v=g7qx5oYdOEA

tous fashos: juif, chrétien, musulmans,...

Il n'y a bien que les communistes qui ont compris que les 
religions c'est de la merde.


Re: Variable below zero but if statement doesn't grab?

2015-12-28 Thread jkpl via Digitalmars-d-learn

On Monday, 28 December 2015 at 15:50:06 UTC, Basile B. wrote:

On Monday, 28 December 2015 at 15:07:08 UTC, jkpl wrote:

On Sunday, 27 December 2015 at 16:00:34 UTC, jkpl wrote:

On Sunday, 27 December 2015 at 15:53:55 UTC, TheDGuy wrote:

Any idea what i am doing wrong?
https://www.youtube.com/watch?v=j_VCa-5VeP8


You could post the code also, personnaly I'm always almost at 
2 meters from my screen, with zoom, so I can't read the 
code...


I work more or less lying on a futon. Desks are so cheesy...


Anarchism is comfy...


when I'm tired with the conformism I just let my head go on the 
pillow and I sleep...

(snoring)

Even if I dont't think that you have won:
https://youtu.be/Uj_7kTwRMKE?t=2m35s


Re: Variable below zero but if statement doesn't grab?

2015-12-28 Thread rumbu via Digitalmars-d-learn

On Sunday, 27 December 2015 at 23:24:55 UTC, TheDGuy wrote:

On Sunday, 27 December 2015 at 22:51:27 UTC, Ali Çehreli wrote:

On 12/27/2015 07:53 AM, TheDGuy wrote:

Any idea what i am doing wrong?
https://www.youtube.com/watch?v=j_VCa-5VeP8


YouTube says that the video has been removed by the user. 
That's exactly the reason why I don't like even dpaste. There 
is no guarantee that such threads will be useful forever. :) 
For me, sample code should be right here, and it should be 
short enough to practically be here.


Ali


I deleted the video because the problem was solved, it was 
neither a problem with the single '&' nor with my code it just 
showed a strange behaviour while debugging but the function 
returned the right value. Sample code is in my second post.


Get used to it :) Unfortunately, DMD is not emitting the best 
debug information. The program flow is correct, but the line info 
is not, that's why the execution step will not be triggered in 
the real location of the source code.


The simplest example is this:

import std.stdio;

void foo(int x)
{
if (x > 0)  //step 1, correct
{
writeln("bigger");  //step 2, correct
}
else
{
writeln("lower");   //step 3, wrong
}
}

int main(string[] argv)
{
foo(20);   //breakpoint with step in
return 0;
}

If you really want to confuse the debugger, write some asserts or 
contracts here and there and your program will be impossible to 
debug :)


Re: How to config the GDC on linux target for ARM linux?

2015-12-28 Thread FrankLike via Digitalmars-d-learn

On Monday, 28 December 2015 at 15:23:19 UTC, FrankLike wrote:
 New Answer: I've gotten the answer: use the difference 'gcc' for 
c code.

 ---For x86_64:
 #! /bin/sh
 dfiles="max31855.d max5322.d mcp23008.d mcp23016.d
 mcp23016reg.d mcp23017.d mcp23s08.d mcp23s17.d mcp23x08.d
 mcp23x0817.d mcp3002.d mcp3004.d mcp3422.d mcp4802.d pcf8574.d
 pcf8591.d sn3218.d softPwm.d softServo.d softTone.d sr595.d
 wiringPi.d wiringPiI2C.d wiringPiSPI.d wiringSerial.d
 wiringShift.d wpiExtensions.d"

 ofiles="drcSerial.o max31855.o max5322.o mcp23008.o mcp23016.o
 mcp23017.o mcp23s08.o mcp23s17.o mcp3002.o mcp3004.o mcp3422.o
 mcp4802.o pcf8574.o pcf8591.o piHiPri.o piThread.o sn3218.o
 softPwm.o softServo.o softTone.o sr595.o wiringPi.o
 wiringPiI2C.o wiringPiSPI.o wiringSerial.o wiringShift.o
 wpiExtensions.o"


 gcc -c *.c -m64
 /opt/x86_64-pc-linux-gnu/bin/x86_64-linux-gnu-gdc -o my my.d
 $ofiles -I$dfiles

 For ARM(add -I.):

 #! /bin/sh
 cfiles="wiringPi.c max31855.c max5322.c mcp23008.c mcp23016.c
 mcp23017.c mcp23s08.c mcp23s17.c mcp3002.c mcp3004.c mcp3422.c
 mcp4802.c pcf8574.c pcf8591.c sn3218.c softPwm.c softServo.c
 softTone.c sr595.c  wiringPiI2C.c wiringPiSPI.c wiringSerial.c
 wiringShift.c wpiExtensions.c"

 dfiles="max31855.d max5322.d mcp23008.d mcp23016.d
 mcp23016reg.d mcp23017.d mcp23s08.d mcp23s17.d mcp23x08.d
 mcp23x0817.d mcp3002.d mcp3004.d mcp3422.d mcp4802.d pcf8574.d
 pcf8591.d sn3218.d softPwm.d softServo.d softTone.d sr595.d
 wiringPi.d wiringPiI2C.d wiringPiSPI.d wiringSerial.d
 wiringShift.d wpiExtensions.d"

 ofiles="drcSerial.o max31855.o max5322.o mcp23008.o mcp23016.o
 mcp23017.o mcp23s08.o mcp23s17.o mcp3002.o mcp3004.o mcp3422.o
 mcp4802.o pcf8574.o pcf8591.o piHiPri.o piThread.o sn3218.o
 softPwm.o softServo.o softTone.o sr595.o wiringPi.o
 wiringPiI2C.o wiringPiSPI.o wiringSerial.o wiringShift.o
 wpiExtensions.o"

 
/opt/arm-unknown-linux-gnueabihf/bin/arm-unknown-linux-gnueabihf-gcc -marm  -c $cfiles -I.
 
/opt/arm-unknown-linux-gnueabihf/bin/arm-unknown-linux-gnueabihf-gdc  -o my my.d   $ofiles -I$dfiles





Re: Variable below zero but if statement doesn't grab?

2015-12-28 Thread Basile B. via Digitalmars-d-learn

On Monday, 28 December 2015 at 15:07:08 UTC, jkpl wrote:

On Sunday, 27 December 2015 at 16:00:34 UTC, jkpl wrote:

On Sunday, 27 December 2015 at 15:53:55 UTC, TheDGuy wrote:

Any idea what i am doing wrong?
https://www.youtube.com/watch?v=j_VCa-5VeP8


You could post the code also, personnaly I'm always almost at 
2 meters from my screen, with zoom, so I can't read the code...


I work more or less lying on a futon. Desks are so cheesy...


Anarchism is comfy...




Re: How to use GDC to get .a file on Linux?

2015-12-28 Thread FrankLike via Digitalmars-d-learn

Answer is here:
http://forum.dlang.org/thread/txvntyahlaewutzzw...@forum.dlang.org




Re: GDC build wiringPi for 'Raspberry Pi',here is error info

2015-12-28 Thread FrankLike via Digitalmars-d-learn

Answer is here:
http://forum.dlang.org/thread/txvntyahlaewutzzw...@forum.dlang.org


Re: How to config the GDC on linux target for ARM linux?

2015-12-28 Thread FrankLike via Digitalmars-d-learn

 I've gotten the answer: use the difference 'gcc' for c code.
---For x86_64:
#! /bin/sh
dfiles="max31855.d max5322.d mcp23008.d mcp23016.d mcp23016reg.d 
mcp23017.d mcp23s08.d mcp23s17.d mcp23x08.d mcp23x0817.d 
mcp3002.d mcp3004.d mcp3422.d mcp4802.d pcf8574.d pcf8591.d 
sn3218.d softPwm.d softServo.d softTone.d sr595.d wiringPi.d 
wiringPiI2C.d wiringPiSPI.d wiringSerial.d wiringShift.d 
wpiExtensions.d"


ofiles="drcSerial.o max31855.o max5322.o mcp23008.o mcp23016.o  
mcp23017.o mcp23s08.o mcp23s17.o mcp3002.o mcp3004.o mcp3422.o 
mcp4802.o pcf8574.o pcf8591.o piHiPri.o piThread.o sn3218.o 
softPwm.o softServo.o softTone.o sr595.o wiringPi.o wiringPiI2C.o 
wiringPiSPI.o wiringSerial.o wiringShift.o wpiExtensions.o"



gcc -c *.c -m64
/opt/x86_64-pc-linux-gnu/bin/x86_64-linux-gnu-gdc -o my my.d   
$ofiles -I$dfiles


For ARM:

#! /bin/sh
cfiles="wiringPi.c max31855.c max5322.c mcp23008.c mcp23016.c  
mcp23017.c mcp23s08.c mcp23s17.c mcp3002.c mcp3004.c mcp3422.c 
mcp4802.c pcf8574.c pcf8591.c sn3218.c softPwm.c softServo.c 
softTone.c sr595.c  wiringPiI2C.c wiringPiSPI.c wiringSerial.c 
wiringShift.c wpiExtensions.c"


dfiles="max31855.d max5322.d mcp23008.d mcp23016.d mcp23016reg.d 
mcp23017.d mcp23s08.d mcp23s17.d mcp23x08.d mcp23x0817.d 
mcp3002.d mcp3004.d mcp3422.d mcp4802.d pcf8574.d pcf8591.d 
sn3218.d softPwm.d softServo.d softTone.d sr595.d wiringPi.d 
wiringPiI2C.d wiringPiSPI.d wiringSerial.d wiringShift.d 
wpiExtensions.d"


ofiles="drcSerial.o max31855.o max5322.o mcp23008.o mcp23016.o  
mcp23017.o mcp23s08.o mcp23s17.o mcp3002.o mcp3004.o mcp3422.o 
mcp4802.o pcf8574.o pcf8591.o piHiPri.o piThread.o sn3218.o 
softPwm.o softServo.o softTone.o sr595.o wiringPi.o wiringPiI2C.o 
wiringPiSPI.o wiringSerial.o wiringShift.o wpiExtensions.o"


/opt/arm-unknown-linux-gnueabihf/bin/arm-unknown-linux-gnueabihf-gcc -marm  -c 
$cfiles
/opt/arm-unknown-linux-gnueabihf/bin/arm-unknown-linux-gnueabihf-gdc  -o my 
my.d   $ofiles -I$dfiles


Re: Variable below zero but if statement doesn't grab?

2015-12-28 Thread jkpl via Digitalmars-d-learn

On Sunday, 27 December 2015 at 16:00:34 UTC, jkpl wrote:

On Sunday, 27 December 2015 at 15:53:55 UTC, TheDGuy wrote:

Any idea what i am doing wrong?
https://www.youtube.com/watch?v=j_VCa-5VeP8


You could post the code also, personnaly I'm always almost at 2 
meters from my screen, with zoom, so I can't read the code...


I work more or less lying on a futon. Desks are so cheesy...


vibe.d / GUI integration

2015-12-28 Thread Robert M. Münch via Digitalmars-d-learn

Hi, I have two questions regarding the following, IMO very cool, vibe feature:

"Contrary to most other frameworks supporting asynchronous I/O, vibe.d 
fully integrates with the UI event loop, so that it can be used to 
power applications with a graphical user interface."


1. Am I right, that there is no GUI event handling for OSX support yet? 
If, are there are any technical limitations in vibe that it couldn't be 
added?


2. Are there are any examples WRT to using vibe with a GUI event loop?

Best regards.

--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



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 why. A few have 64K link 
errors no idea why.



TIA,
Steven


what's up ?

;)

Did you upload, so that bugs can be verified ?


As the original poster mentioned RosettaCode, perhaps they are 
just programs from http://rosettacode.org/wiki/D ?  There are 742 
entries, but some (like 
http://rosettacode.org/wiki/99_Bottles_of_Beer#D) contain more 
than one D program.


Re: Multiple selective imports on one line

2015-12-28 Thread Joakim via Digitalmars-d-learn

On Monday, 28 December 2015 at 14:16:36 UTC, Basile B. wrote:

On Monday, 28 December 2015 at 14:09:30 UTC, Joakim wrote:
I wish dfmt could do this for us, so that you develop with all 
the modules imported at the top, then run dfmt and it scopes 
all the imports and adds the selective import of symbols.  
I've been thinking about implementing a tool to do this 
myself, will get around to it someday.


This is not formating (what DFMT is aimed to do) this is 
refactoring.


You're right, I was thinking about patching Dscanner to do it, 
just mentioned dfmt here without thinking about that aspect.


Re: Lots of D code

2015-12-28 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 23 December 2015 at 00:59:53 UTC, steven kladitis 
wrote:
I have 843 programs written in D. 805 actually create an 32 bit 
exe in windows 10. I am running the latest D.  Some just start 
to link and the linker disappears. Some just have issues I am  
not able figure out. I can attach the code and scripts I use to 
compile and run these. If anyone is willing to figure out why 
the 38 do not compile, I would appreciate code that works.  The 
execute_bf_v2.d creates an exe that is small but takes about 1 
hour to link on a 12 core processor with 64g of ram as 14tb of 
disk space. The rest link very fast.  If anyone is interested, 
let me know.  I would love to get the 38 working.  Also there 
are a few that produce incorrect answers.  The Generate_maze.d  
produces all but the last line of the maze.  I added a line 
just for it.  I do not understand why.  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 why. A few have 64K link errors no idea why.



TIA,
Steven


what's up ?

;)

Did you upload, so that bugs can be verified ?


Re: Must I compile on the target architecture?

2015-12-28 Thread Joakim via Digitalmars-d-learn

On Friday, 25 December 2015 at 12:43:05 UTC, Jakob Jenkov wrote:

Hi, just a quick question:

If I write a program in D and I use Windows for development but 
want it to run on Linux, do I have to copy the source code to 
the target Linux machine and compile it there, to make an 
executable for that machine? What is the standard process for 
cross platform compilation?


I'll also note that ldc supports cross-compilation out of the 
box.  The only issue is that you'll need a linker to link the 
resulting objects, but you can usually install one in Cygwin.  I 
believe gdc also supports some cross-compilation, though I've not 
tried it.  Dmd isn't a cross-compiler, though it is capable of 
being turned into one: nobody has put in the remaining work yet.


Re: Multiple selective imports on one line

2015-12-28 Thread Basile B. via Digitalmars-d-learn

On Monday, 28 December 2015 at 14:16:36 UTC, Basile B. wrote:

On Monday, 28 December 2015 at 14:09:30 UTC, Joakim wrote:
I wish dfmt could do this for us, so that you develop with all 
the modules imported at the top, then run dfmt and it scopes 
all the imports and adds the selective import of symbols.  
I've been thinking about implementing a tool to do this 
myself, will get around to it someday.


This is not formating (what DFMT is aimed to do) this is 
refactoring.


oops, my answer could lead to a misunderstanding. I meant:

This is not formating (what DFMT is aimed to do), but rather 
refactoring.




Re: Multiple selective imports on one line

2015-12-28 Thread Basile B. via Digitalmars-d-learn

On Monday, 28 December 2015 at 14:09:30 UTC, Joakim wrote:
I wish dfmt could do this for us, so that you develop with all 
the modules imported at the top, then run dfmt and it scopes 
all the imports and adds the selective import of symbols.  I've 
been thinking about implementing a tool to do this myself, will 
get around to it someday.


This is not formating (what DFMT is aimed to do) this is 
refactoring.


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 for an N-element heap 
anyway (or quadratic time and constant memory).  So, you can 
just copy the array and exhaust the copied binary heap, 
getting the same asymptotic complexity: N log N time and N 
additional memory.


Thanks. I wanted to iterate through the range without modifying 
the original array but like you said the only way to do that is 
by copying the data which is not ideal.


Hmm.  On second thought:

1. You can find maximum, then second maximum, then third maximum 
and so on - each in constant memory and linear time.  So, if 
performance is somehow not an issue, there is a way to do it 
@nogc but in N^2 operations.


2. If you output the whole array anyway, you may sort the array 
in place.  A sorted array obeys the heap property, so subsequent 
heap operations will still work.


3. The tricky part is when we want to support parallel iteration 
over the same heap.  If we look closely at one iteration of 
heapsort algorithm, it will perhaps become clear how to output 
values so that the array is a heap between any two consecutive 
output operations.  At the very least, our heap struct over the 
array can just track which part of the array is already sorted, 
and work with it separately.


4. Reading and modifying the heap in parallel at the same time 
does not look possible anyway, so this is as far as we can get.


Ivan Kazmenko.



Re: Multiple selective imports on one line

2015-12-28 Thread Joakim via Digitalmars-d-learn

On Wednesday, 23 December 2015 at 10:51:52 UTC, earthfront wrote:
I'm using hackerpilot's excellent textadept plugin + DCD, Dfmt, 
and Dscanner.
Upon saving files, it produces suggestions, much like warnings 
from the compiler.


One suggestion is to use selective imports in local scopes. OK, 
I'll do that.


Now I'm left with a smattering of lines which are just 
selective imports from a single module:

void foo()
{
  import std.exception:enforce;
  import std.algorithm:array;
  import std.algorithm.iteration:filter;
  import std.functional:memoize;

  //..Work..
}

What is the proper way to combine these into one line?


You really shouldn't have to do this by hand.  I wish dfmt could 
do this for us, so that you develop with all the modules imported 
at the top, then run dfmt and it scopes all the imports and adds 
the selective import of symbols.  I've been thinking about 
implementing a tool to do this myself, will get around to it 
someday.


Re: How to config the GDC on linux target for ARM linux?

2015-12-28 Thread FrankLike via Digitalmars-d-learn

On Monday, 28 December 2015 at 13:17:04 UTC, FrankLike wrote:
About the first error ("...module wiringPi is in file 
'wiringPi.d' which cannot be read...") - are you sure that the 
dfiles are in "./wiringPi/WiringPi/"? The compiler reports 
that it can't find them there.
You can try copying the WiringPi dfiles in the same folder as 
"my.d".


About the second error - you need to verify that aa.so 
actually has those symbols that the linker reports as 
"undefined reference". You can do this with readlelf or nm. 
For more info see 
here:http://stackoverflow.com/questions/1237575/how-do-i-find-out-what-all-symbols-are-exported-from-a-shared-object


 Thank you,but can you tell me that what is right way to use GDC
 on linux,such as d refer a c lib.
for eacample:
a.d refer  x.h x.c
 how  do you build it by GDC?
 what's your steps?
 How to config the GDC for the third part c libaries and d 
files,such as PATH.


 Thank you,waiting for your answer.




Re: How to config the GDC on linux target for ARM linux?

2015-12-28 Thread FrankLike via Digitalmars-d-learn
About the first error ("...module wiringPi is in file 
'wiringPi.d' which cannot be read...") - are you sure that the 
dfiles are in "./wiringPi/WiringPi/"? The compiler reports that 
it can't find them there.
You can try copying the WiringPi dfiles in the same folder as 
"my.d".


About the second error - you need to verify that aa.so actually 
has those symbols that the linker reports as "undefined 
reference". You can do this with readlelf or nm. For more info 
see 
here:http://stackoverflow.com/questions/1237575/how-do-i-find-out-what-all-symbols-are-exported-from-a-shared-object


Thank you,but can you tell me that what is right way to use GDC 
on linux,such as d refer a c lib.

for eacample:
a.d refer  x.h x.c
how  do you build it by GDC?
what's your steps?
How to config the GDC for the thirty c lib and d files.

Thank you,waiting for your answer.


Re: How to use GDC to get .a file on Linux?

2015-12-28 Thread FrankLike via Digitalmars-d-learn

On Sunday, 27 December 2015 at 17:19:26 UTC, Mike Parker wrote:

On Sunday, 27 December 2015 at 15:19:21 UTC, FrankLike wrote:

Hi,
   Now I need get the .a file on Linux,target system is ARM.
   If you use gcc ,you will use the 'ar' to get .a file,
but how to do by GDC ?
And how to  get the execute file by .a file and .d file?

Thank you.


Just use ar on the generated object files the same way you 
would if you were using gcc.


Thank you,but the error is not ok.maybe some PATH is error,I 
don't how to set.


Re: are MRV as an optimization well known ?

2015-12-28 Thread Basile B. via Digitalmars-d-learn

On Monday, 28 December 2015 at 12:40:09 UTC, Basile B. wrote:
I mean it's maybe "just" a special case of RVO, since tuples 
are processed as structs ?


Also in the second version the stack size is modified by 78 
bytes. Not when using MRV.


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

2015-12-28 Thread Gary Willoughby via Digitalmars-d-learn

On Sunday, 27 December 2015 at 22:42:21 UTC, Ivan Kazmenko wrote:
If you implement a struct with range primitives over it, you 
can use it as a range.


See the second code example in std.container.binaryheap's docs 
at

http://dlang.org/phobos/std_container_binaryheap.html#.BinaryHeap.

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 for an N-element heap anyway 
(or quadratic time and constant memory).  So, you can just copy 
the array and exhaust the copied binary heap, getting the same 
asymptotic complexity: N log N time and N additional memory.


Ivan Kazmenko.


Thanks. I wanted to iterate through the range without modifying 
the original array but like you said the only way to do that is 
by copying the data which is not ideal.


std.container.binaryheap looks like it implements the range 
interface and consumes the original during iteration. I'll 
probably do that too.


Re: are MRV as an optimization well known ?

2015-12-28 Thread Basile B. via Digitalmars-d-learn
I mean it's maybe "just" a special case of RVO, since tuples are 
processed as structs ?





are MRV as an optimization well known ?

2015-12-28 Thread Basile B. via Digitalmars-d-learn
While working on a framework, I've found that Multiple Return 
Values (MRV) are clearly an optimization. I'de like to write a 
small D blog post about this but I don't know If it's clever 
enough or if it's a well know fact.


My base D material is this:

---
#!runnable-flags: -O -boundscheck=off -release
module runnable;

struct Get
{
static auto all()
{
import std.typecons;
return tuple(0.1f,0.2f,0.3f,0.4f);
}
static float a(){return 0.1f;}
static float b(){return 0.2f;}
static float c(){return 0.3f;}
static float d(){return 0.4f;}
}

void call(float a, float b, float c, float d){}

void tupYes()
{
call(Get.all[0..$]);
}

void tupNo()
{
call(Get.a, Get.b, Get.c, Get.d);
}

void main(string[] args)
{
import disassembler;
import std.stdio;

symbolTable.addModule!runnable;
writeln(prettyDisasm(&tupYes));
writeln;
writeln(prettyDisasm(&tupNo));
}
---

with my d beaengine bindings I get this (bin comes from DMD 
backend) :


;--- SUB 0044C918h ---
; NAMED: tupYes
0044C918h  push rbp
0044C919h  mov rbp, rsp
0044C91Ch  sub rsp, 20h
0044C920h  call 0044C8A0h
0044C925h  movsd qword ptr [rbp-20h], xmm0
0044C92Ah  fld qword ptr [rbp-20h]
0044C92Dh  movsd qword ptr [rbp-20h], xmm1
0044C932h  fld qword ptr [rbp-20h]
0044C935h  fstp qword ptr [rbp-08h]
0044C938h  fstp qword ptr [rbp-10h]
0044C93Bh  movss xmm3, dword ptr [rbp-10h]
0044C940h  movss xmm2, dword ptr [rbp-0Ch]
0044C945h  movss xmm1, dword ptr [rbp-08h]
0044C94Ah  movss xmm0, dword ptr [rbp-04h]
0044C94Fh  call 0044C910h ; (call)
0044C954h  mov rsp, rbp
0044C957h  pop rbp
0044C958h  ret
;-

;--- SUB 0044C960h ---
; NAMED: tupNo
0044C960h  sub rsp, 78h
0044C964h  call 0044C8D0h
0044C969h  movss dword ptr [rsp], xmm0
0044C96Eh  movss xmm3, dword ptr [rsp]
0044C973h  movapd dqword ptr [rsp+10h], xmm3
0044C979h  call 0044C8E0h
0044C97Eh  movss dword ptr [rsp], xmm0
0044C983h  movss xmm2, dword ptr [rsp]
0044C988h  movapd xmm3, dqword ptr [rsp+10h]
0044C98Eh  movapd dqword ptr [rsp+20h], xmm2
0044C994h  movapd dqword ptr [rsp+30h], xmm3
0044C99Ah  call 0044C8F0h
0044C99Fh  movss dword ptr [rsp], xmm0
0044C9A4h  movss xmm1, dword ptr [rsp]
0044C9A9h  movapd xmm2, dqword ptr [rsp+20h]
0044C9AFh  movapd xmm3, dqword ptr [rsp+30h]
0044C9B5h  movapd dqword ptr [rsp+40h], xmm1
0044C9BBh  movapd dqword ptr [rsp+50h], xmm2
0044C9C1h  movapd dqword ptr [rsp+60h], xmm3
0044C9C7h  call 0044C900h
0044C9CCh  movapd xmm1, dqword ptr [rsp+40h]
0044C9D2h  movapd xmm2, dqword ptr [rsp+50h]
0044C9D8h  movapd xmm3, dqword ptr [rsp+60h]
0044C9DEh  call 0044C910h ; (call)
0044C9E3h  add rsp, 78h
0044C9E7h  ret
;-

Which clearly shows that using the MRV version is faster than 
grabing each property, since in the second, version there's a 
call for each parameter.


When I google "MRV optimization tuple", there's nothing, maybe 
some garbages from the early 2000's...nothing else. I'd like your 
mind before writing something possibly ridiculous.


Re: GTKD drawing area remains white even SourceRgb is changed

2015-12-28 Thread Mike Wey via Digitalmars-d-learn

On 12/28/2015 12:29 AM, TheDGuy wrote:

My code:

http://dpaste.com/1X3E1HW

i store colors in the accumulator-array and draw them via
"cr.rectangle()". Because i have some problems with the code i set the
SourceRgb-color to a constant value but if i execute the program, the
window remains white.


The values passed to setSourceRgb should be between 0 and 1.

--
Mike Wey


Re: How to config the GDC on linux target for ARM linux?

2015-12-28 Thread ZombineDev via Digitalmars-d-learn

On Monday, 28 December 2015 at 04:52:44 UTC, FrankLike wrote:
Now I build a project for ARM linux on ubuntu 15.04 ,but build 
error.
I download the 'wiringPi' from http://wiringPi.com,convert the 
*.h to *.d.then build the 'aa.so' file:

#! /bin/sh
dfiles="max31855.d max5322.d mcp23008.d mcp23016.d 
mcp23016reg.d mcp23017.d mcp23s08.d mcp23s17.d mcp23x08.d 
mcp23x0817.d mcp3002.d mcp3004.d mcp3422.d mcp4802.d pcf8574.d 
pcf8591.d sn3218.d softPwm.d softServo.d softTone.d sr595.d 
wiringPi.d wiringPiI2C.d wiringPiSPI.d wiringSerial.d 
wiringShift.d wpiExtensions.d"


ofiles="drcSerial.o max31855.o max5322.o mcp23008.o mcp23016.o  
mcp23017.o mcp23s08.o mcp23s17.o mcp3002.o mcp3004.o mcp3422.o 
mcp4802.o pcf8574.o pcf8591.o piHiPri.o piThead.o sn3218.o 
softPwm.o softServo.o softTone.o sr595.o wiringPi.o 
wiringPiI2C.o wiringPiSPI.o wiringSerial.o wiringShift.o 
wpiExtensions.o"


 /opt/arm-unknown-linux-gnueabihf/bin/arm-linux-gnueabihf-gdc  
-o aa.so $ofiels $dfiles  -shared

---my.d
import wiringPi;
import std.stdio;

void main()
{
writeln("start");
wiringPiSetup();
pinMode(0,OUTPUT);
while(1)
{
digitalWrite(0,HIGH);
delay(500);
digitalWrite(0,LOW);
delay(500);
}
return;
}
-build the my execute file
/opt/arm-unknown-linux-gnueabihf/bin/arm-linux-gnueabihf-gdc  
-o my  my.d aa.so -I./wiringPi/WiringPi/


-now get the error:
my.d:1:8: error: module wiringPi is in file 'wiringPi.d' which 
cannot be read

 import wiringPi;
^
import path[0] = 
/opt/arm-unknown-linux-gnueabihf/lib/gcc/arm-unknown-linux-gnueabihf/5.2.0/include/d
-I copy the *.d to 
/opt/arm-unknown-linux-gnueabihf/lib/gcc/arm-unknown-linux-gnueabihf/5.2.0/include/d

it's ok ,but where is the file for config?
-get another error:
/tmp/cc7M1B9I.o: In function `_Dmain':
my.d:(.text+0x60): undefined reference to `wiringPiSetup'
my.d:(.text+0x6c): undefined reference to `pinMode'
my.d:(.text+0x84): undefined reference to `digitalWrite'
my.d:(.text+0x8c): undefined reference to `delay'
my.d:(.text+0x98): undefined reference to `digitalWrite'
my.d:(.text+0xa0): undefined reference to `delay'
collect2: error: ld returned 1 exit status
-end

I'm not known the GDC config file ,and maybe I use the error 
build .

Who can help me?
 thank you.


About the first error ("...module wiringPi is in file 
'wiringPi.d' which cannot be read...") - are you sure that the 
dfiles are in "./wiringPi/WiringPi/"? The compiler reports that 
it can't find them there.
You can try copying the WiringPi dfiles in the same folder as 
"my.d".


About the second error - you need to verify that aa.so actually 
has those symbols that the linker reports as "undefined 
reference". You can do this with readlelf or nm. For more info 
see 
here:http://stackoverflow.com/questions/1237575/how-do-i-find-out-what-all-symbols-are-exported-from-a-shared-object