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

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: 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

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: 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/?page=show T

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: 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 style. What is your

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: 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, floats are auto

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: 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; your_array.le

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; your_array.le

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-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", &nam[0][num], &nam[1][num]); T

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); nam.length = 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); nam.length = num

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 main()

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 what you mean

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 o

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!

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 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

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
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'. I added the writefln() stat

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, " "); readf(" %d", &liaOrig

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: 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 style. What is your

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) { writeln

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; 0