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

Using Hashtags with posts

2017-04-04 Thread Binarydepth via Digitalmars-d
So I've been a member of Ask Ubuntu at Stack Exchange for a while now. I saw the tags could be useful here: Someone could search Metaprogramming, OOP, Imperative, Data type, Arrays and find something inside the DLearn section. That could work along with a post tutorial session.

Re: Always false float comparisons

2016-05-14 Thread Binarydepth via Digitalmars-d
On Monday, 9 May 2016 at 11:26:55 UTC, Walter Bright wrote: I wonder what's the difference between 1.30f and cast(float)1.30. There isn't one. I always saw type casting happening @ run-time and "literals" (pardon if that's not the correct term) to happen during compilation. I know that

Re: Always false float comparisons

2016-05-14 Thread Binarydepth via Digitalmars-d
On Saturday, 14 May 2016 at 20:41:12 UTC, Era Scarecrow wrote: writeln(f == 1.30f); writeln(cf == 1.30f); writeln(If == 1.30f); I guess this returned True ?

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

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

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

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

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

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

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
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(nim;

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

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]); Those

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

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;

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

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]; }

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

Re: Daily downloads in decline

2015-06-10 Thread Binarydepth via Digitalmars-d
On Monday, 1 June 2015 at 18:11:32 UTC, Andrei Alexandrescu wrote: Per http://erdani.com/d/downloads.daily.png, the 28-day moving average of daily dmd downloads is in pronounced decline following a peak at the 2.067 release. It is possible that the recent release of Rust 1.0 has caused that,

It may be useful to allow declaring variables without type

2015-06-10 Thread Binarydepth via Digitalmars-d
I think that it could be useful to declare variables as Python does and statically too in the same language. Just make it's type when a value is assigned to the variable. This could allow a program to adjust it's data types accordingly to input when data is received from another program or an

Re: Daily downloads in decline

2015-06-10 Thread Binarydepth via Digitalmars-d
On Wednesday, 10 June 2015 at 18:04:45 UTC, Andrei Alexandrescu wrote: On 6/10/15 10:36 AM, Binarydepth wrote: On Monday, 1 June 2015 at 18:11:32 UTC, Andrei Alexandrescu wrote: Per http://erdani.com/d/downloads.daily.png, the 28-day moving average of daily dmd downloads is in pronounced

Re: Daily downloads in decline

2015-06-10 Thread Binarydepth via Digitalmars-d
On Monday, 1 June 2015 at 18:11:32 UTC, Andrei Alexandrescu wrote: Per http://erdani.com/d/downloads.daily.png, the 28-day moving average of daily dmd downloads is in pronounced decline following a peak at the 2.067 release. It is possible that the recent release of Rust 1.0 has caused that,

Re: It may be useful to allow declaring variables without type

2015-06-10 Thread Binarydepth via Digitalmars-d
On Wednesday, 10 June 2015 at 17:13:33 UTC, Adam D. Ruppe wrote: You can do this with variants or even just plain strings. Hi, If it is not much trouble, care to explain how ?. I think that there would be need to have separate algorithms by data type. Maybe you can test the value of the data

Re: It may be useful to allow declaring variables without type

2015-06-10 Thread Binarydepth via Digitalmars-d
On Wednesday, 10 June 2015 at 17:32:18 UTC, Atila Neves wrote: On Wednesday, 10 June 2015 at 17:04:20 UTC, Binarydepth wrote: I think that it could be useful to declare variables as Python does and statically too in the same language. Just make it's type when a value is assigned to the

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

Re: Any GPL video games in D2

2014-06-25 Thread Binarydepth via Digitalmars-d-learn
there. 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 action to other

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