To learn D

2019-07-05 Thread Binarydepth via Digitalmars-d-learn
I've considering learning full D. I remembered that D is not recommended as a first language, So I read time ago. So my question, is learning C and Python a good intro before learning D? TY

Re: I'm getting NAN out of nowhere

2017-04-10 Thread Binarydepth via Digitalmars-d-learn
On Monday, 13 July 2015 at 14:29:57 UTC, Steven Schveighoffer wrote: On 7/11/15 12:57 PM, flamencofantasy wrote: On Thursday, 9 July 2015 at 15:14:43 UTC, Binarydepth wrote: This is my code : import std.stdio : writeln, readf; void main(){ int[3] nums; float prom; foreach(nem

Re: I'm getting NAN out of nowhere

2017-04-10 Thread Binarydepth via Digitalmars-d-learn
On Saturday, 11 July 2015 at 16:57:55 UTC, flamencofantasy wrote: On Thursday, 9 July 2015 at 15:14:43 UTC, Binarydepth wrote: This is my code : import std.stdio : writeln, readf; void main() { int[3] nums; float prom; foreach(nem; 0..2

Re: Importing local modules in C style

2015-08-10 Thread Binarydepth via Digitalmars-d-learn
On Thursday, 25 June 2015 at 14:10:00 UTC, Steven Schveighoffer wrote: On 6/25/15 9:57 AM, Binarydepth wrote: I want to import a module from my local project in C style (#include "local.h"). No. I know I can do "dmd main.d local.d" but I wonder if it can be done C s

Re: Dynamic array and foreach loop

2015-08-09 Thread Binarydepth via Digitalmars-d-learn
On Sunday, 9 August 2015 at 16:42:16 UTC, Jay Norwood wrote: The i+3 initialization is just so you can see that v is the Arr member (not the index) in the other loops. import std.stdio : writeln; void main() { immutable a=5; int[a] Arr; foreach(i, ref v; Arr) {

Re: Dynamic array and foreach loop

2015-08-09 Thread Binarydepth via Digitalmars-d-learn
On Sunday, 9 August 2015 at 00:22:53 UTC, Jay Norwood wrote: On Saturday, 8 August 2015 at 18:28:25 UTC, Binarydepth wrote: This is the new code : foreach(num; 0..liEle) {//Data input loop write("Input the element : ", num+1, " ");

Re: Dynamic array and foreach loop

2015-08-08 Thread Binarydepth via Digitalmars-d-learn
On Saturday, 8 August 2015 at 18:24:48 UTC, Binarydepth wrote: On Saturday, 8 August 2015 at 17:19:08 UTC, DarthCthulhu wrote: Now 'num' is just an iterative number starting from 0 (the .init value of an int), while the actual element value is stored in 'element'.

Re: Dynamic array and foreach loop

2015-08-08 Thread Binarydepth via Digitalmars-d-learn
On Saturday, 8 August 2015 at 17:19:08 UTC, DarthCthulhu wrote: You can fix it like the following: foreach(num, element; liaOrig) {//Data input loop writefln("num: %s current element: %s liaOrig.length: %s", num, element, liaOrig.length); write("In

Re: Dynamic array and foreach loop

2015-08-08 Thread Binarydepth via Digitalmars-d-learn
Here's what happens : How many elements need to be used? 5 Input the element : 1 1 Input the element : 1 2 Input the element : 1 3 Input the element : 1 4 Input the element : 1 5 How many positions do you wish to rotate ? 3 The original patter is : 5 0 0 0 0 The final is : 0 0 0 5 0 Do you want t

Dynamic array and foreach loop

2015-08-08 Thread Binarydepth via Digitalmars-d-learn
I'm writing a program that rotates numbers then asks the user if a new set of numbers should be rotated. I'm having trouble using a Foreach loop to fill a dynamic array with the elements to be rotated. Here's my code, I add a TAB when a loop is inside a loop and and do that too to the stateme

Re: Dynamic memory

2015-07-29 Thread Binarydepth via Digitalmars-d-learn
On Wednesday, 29 July 2015 at 08:03:06 UTC, anonymous wrote: int[2][] is exactly an dynamic array of (arrays with the length 2), the logic behind this notation is: 1. Array of 2 int -> int[2] 2. a dynamic array of 1. -> int[2][] (like SomeType[] is an array of SomeType) Thank you!

Re: Dynamic memory

2015-07-28 Thread Binarydepth via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 17:34:46 UTC, Steven Schveighoffer wrote: On 7/28/15 1:26 PM, Binarydepth wrote: On Tuesday, 28 July 2015 at 17:07:47 UTC, Steven Schveighoffer wrote: On 7/28/15 12:59 PM, Binarydepth wrote: When indexing, it always goes out to in. So nam[0] is the first element

Re: Dynamic memory

2015-07-28 Thread Binarydepth via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 17:07:47 UTC, Steven Schveighoffer wrote: On 7/28/15 12:59 PM, Binarydepth wrote: When indexing, it always goes out to in. So nam[0] is the first element of type int[2], and nam[0][0] is the first integer in that first element. -Steve I don't get wha

Re: Dynamic memory

2015-07-28 Thread Binarydepth via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 16:53:35 UTC, anonymous wrote: On Tuesday, 28 July 2015 at 16:41:40 UTC, Binarydepth wrote: It works with 2 as input but shows error when number is 3 :( I can't reproduce that or I misunderstood something: $ cat a.d import std.stdio : readf, writef; void

Re: Dynamic memory

2015-07-28 Thread Binarydepth via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 16:24:39 UTC, anonymous wrote: On Tuesday, 28 July 2015 at 16:09:46 UTC, Binarydepth wrote: Here is what I'm trying to do : import std.stdio : readf, writef; void main() { int[2][] nam; int num; readf(" %d", &num);

Re: Dynamic memory

2015-07-28 Thread Binarydepth via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 16:24:39 UTC, anonymous wrote: On Tuesday, 28 July 2015 at 16:09:46 UTC, Binarydepth wrote: Here is what I'm trying to do : import std.stdio : readf, writef; void main() { int[2][] nam; int num; readf(" %d", &num);

Re: Dynamic memory

2015-07-28 Thread Binarydepth via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 16:12:28 UTC, Adam D. Ruppe wrote: On Tuesday, 28 July 2015 at 16:09:46 UTC, Binarydepth wrote: readf(" %d %d", &nam[0][num], &nam[1][num]); } foreach(nim; 0..num){ writef(" %d %d\n"

Re: Dynamic memory

2015-07-28 Thread Binarydepth via Digitalmars-d-learn
Here is what I'm trying to do : import std.stdio : readf, writef; void main() { int[2][] nam; int num; readf(" %d", &num); nam.length = num; foreach(nim; 0..num){ readf(" %d %d", &nam[0][num], &nam[1][num]); } foreach

Re: Dynamic memory

2015-07-24 Thread Binarydepth via Digitalmars-d-learn
On Friday, 24 July 2015 at 15:26:27 UTC, Adam D. Ruppe wrote: On Friday, 24 July 2015 at 15:22:15 UTC, Binarydepth wrote: I want to use memory based on user input. In this case declare a bi-dimensional array (int[2][var]), var being the user input. Declare: int[2][] your_array

Re: Dynamic memory

2015-07-24 Thread Binarydepth via Digitalmars-d-learn
On Friday, 24 July 2015 at 15:26:27 UTC, Adam D. Ruppe wrote: On Friday, 24 July 2015 at 15:22:15 UTC, Binarydepth wrote: I want to use memory based on user input. In this case declare a bi-dimensional array (int[2][var]), var being the user input. Declare: int[2][] your_array

Dynamic memory

2015-07-24 Thread Binarydepth via Digitalmars-d-learn
How do we get dynamic memory in D ? I want to use memory based on user input. In this case declare a bi-dimensional array (int[2][var]), var being the user input.

Re: I'm getting NAN out of nowhere

2015-07-09 Thread Binarydepth via Digitalmars-d-learn
On Thursday, 9 July 2015 at 15:18:18 UTC, Adam D. Ruppe wrote: On Thursday, 9 July 2015 at 15:14:43 UTC, Binarydepth wrote: float prom; You didn't initialize this variable. Set it to 0.0 and it will work. Like how pointers are initialized to null automatically in D, float

I'm getting NAN out of nowhere

2015-07-09 Thread Binarydepth via Digitalmars-d-learn
This is my code : import std.stdio : writeln, readf; void main() { int[3] nums; float prom; foreach(nem; 0..2) { writeln("input a number : "); readf(" %d", &nums[nem]); prom+=nums[nem]; } writeln(prom/

Re: Importing local modules in C style

2015-06-25 Thread Binarydepth via Digitalmars-d-learn
On Thursday, 25 June 2015 at 14:10:00 UTC, Steven Schveighoffer wrote: On 6/25/15 9:57 AM, Binarydepth wrote: I want to import a module from my local project in C style (#include "local.h"). No. I know I can do "dmd main.d local.d" but I wonder if it can be done C s

Importing local modules in C style

2015-06-25 Thread Binarydepth via Digitalmars-d-learn
I want to import a module from my local project in C style (#include "local.h"). I know I can do "dmd main.d local.d" but I wonder if it can be done C style. Thank you BD

Re: Any GPL video games in D2

2014-06-25 Thread Binarydepth via Digitalmars-d-learn
On Wednesday, 25 June 2014 at 16:37:13 UTC, Namespace wrote: On Wednesday, 25 June 2014 at 14:24:11 UTC, Binarydepth wrote: I would like to show D in "action" to other programmers/students. Anyone knows of a Video Game coded in D2 ? Thank you Here are two: http://dgame-dev.de/

Re: Any GPL video games in D2

2014-06-25 Thread Binarydepth via Digitalmars-d-learn
. And maybe this is not the best code to show to students ;-) Also, license is ZLib -- I assume it will be good for your purposes. LMB On Wed, Jun 25, 2014 at 11:24 AM, Binarydepth via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: I would like to show D in "

Re: How to I call D code from C# Project?

2014-06-25 Thread Binarydepth via Digitalmars-d-learn
On Thursday, 19 June 2014 at 04:07:30 UTC, Jesse Phillips wrote: On Wednesday, 18 June 2014 at 23:41:43 UTC, GoD wrote: @Jesse How to use in C# projects? You'll have to access it through a COM interface on the C# side. http://msdn.microsoft.com/en-us/library/aa645736%28v=vs.71%29.aspx If yo

Any GPL video games in D2

2014-06-25 Thread Binarydepth via Digitalmars-d-learn
I would like to show D in "action" to other programmers/students. Anyone knows of a Video Game coded in D2 ? Thank you

Re: Foreach loop behaviour and manipulation

2014-01-07 Thread Binarydepth
or ... for(count=1;count>0 && count<100 || count>999 && count<1 || etc...; count++ ) That won't work. It's better separate foreach loops.

Re: Foreach loop behaviour and manipulation

2014-01-07 Thread Binarydepth
On Thursday, 28 November 2013 at 23:45:26 UTC, H. S. Teoh wrote: On Fri, Nov 29, 2013 at 12:36:18AM +0100, Binarydepth wrote: Hi guys I'm having some problems. Calculations are not working as expected and I get segmentation fault. I used the 2.059 version and it runs after compilati

Re: Foreach loop behaviour and manipulation

2013-12-02 Thread Binarydepth
foreach (immutable t; 1 .. 51) { int temp = (((t * 20) + 420) * 5) + 3; arr[t - 1] = temp - a; temp = (((t * 5) + 50) * 20) + 1013; arr[t] = temp - a; } Good work with the parenthesis. :)

Re: Foreach loop behaviour and manipulation

2013-12-02 Thread Binarydepth
On Friday, 29 November 2013 at 09:15:28 UTC, Joseph Rushton Wakeling wrote: On 29/11/13 00:36, Binarydepth wrote: I'm wondering in the case of manipulating the variable from the foreach loop, Do I have to reset that variable so the loop can work as intended ?(chronologically). I think

Re: Foreach loop behaviour and manipulation

2013-11-28 Thread Binarydepth
On Thursday, 28 November 2013 at 23:45:26 UTC, H. S. Teoh wrote: On Fri, Nov 29, 2013 at 12:36:18AM +0100, Binarydepth wrote: Hi guys I'm having some problems. Calculations are not working as expected and I get segmentation fault. I used the 2.059 version and it runs after compilati

Re: Foreach loop behaviour and manipulation

2013-11-28 Thread Binarydepth
I fixed a formatting problem on the code just now. And also a note is that the numbers are supposed to display a number depending on the initial value of the variable that the foreach loop is increasing and the users age. So if you were born in 1977 you input your birth year to the program an

Foreach loop behaviour and manipulation

2013-11-28 Thread Binarydepth
Hi guys I'm having some problems. Calculations are not working as expected and I get segmentation fault. I used the 2.059 version and it runs after compilation on compileonline.com But I imagine is either a rookie mistake or a bug, what I'm curious about is the foreach loop. I'm wondering in

Monodevelop 4.2. Exited with code 1

2013-11-25 Thread Binarydepth
Hi guys I'm trying out Mono-D with Monodevelop 4.2 and the compiler seems to build ok but the debugger says Error 1. Here is the sample Hello world code -- import std.stdio; void main() { writeln("Hello World!"); }