Re: Process Pipes

2018-10-10 Thread Colin via Digitalmars-d-learn
On Tuesday, 9 October 2018 at 09:15:09 UTC, Gorker wrote: Hi all, I'm on macOS 10.11.6 with dmd 2.081.2 and I've a problem with std.process. --- gork ():foo gorker$ gcc -c -Iinclude -o foo.cpp.o src/foo.cpp In file included from src/foo.cpp:2: include/foo/foo.hpp:22:10: warning: scoped

Re: Auto keyword and when to use it

2018-08-20 Thread Colin via Digitalmars-d-learn
On Monday, 20 August 2018 at 17:52:17 UTC, QueenSvetlana wrote: Great! So I can't declare class level variables with auto, correct? only local method variables? You can use auto if you're setting the class level variable to a default. class X { auto i = 42; // i will be an int }

Re: Making sense of recursion

2018-06-25 Thread Colin via Digitalmars-d-learn
On Monday, 25 June 2018 at 17:45:01 UTC, zbr wrote: Hi, this question is not specifically D related but I'll just ask anyway. Consider the following snippet: [...] Your mistake is in your visualization :-) But... more like: 0 < 4 ? true : mergeSort(0,2) && mergeSort(3, 4) And so on. I.e,

Re: Error: variable foo conflicts with struct foo

2018-01-04 Thread Colin via Digitalmars-d-learn
On Thursday, 4 January 2018 at 17:45:35 UTC, Stijn wrote: Why is it not allowed for a variable name to match a type name? The following example fails with "Error: variable foo conflicts with struct foo" struct foo {} foo foo; How can the compiler know which symbol is which symbol if

Re: static if and early exit from function doesn't seem to work?

2017-12-31 Thread Colin via Digitalmars-d-learn
On Sunday, 31 December 2017 at 13:32:03 UTC, aliak wrote: Alo! I'm making a recursive concat function that is similar to chain. The following code works: [...] I suspect it's because you've no 'else static if'.

Re: 'real' not able to store it's largest value

2017-05-22 Thread colin via Digitalmars-d-learn
D'oh! Thanks Adam and Ali :)

'real' not able to store it's largest value

2017-05-22 Thread colin via Digitalmars-d-learn
Am I doing something wrong here? real.max evaluates to: 1.18973e+4932 So, I'd expect to be able to store any value up to that... however ``` void main() { writeln("Real max: ", real.max); foreach(i; 0..10){ writefln!("1024 ^^ %s = %s")(i, real(1024 ^^ i)); } } ``` Output:

rdmd with a file with no extension

2017-03-01 Thread Colin via Digitalmars-d-learn
When running a small D program through rdmd, it seems the file needs a .d extension to work. ``` $ ./testscript2 Error: module testscript2 is in file './testscript2.d' which cannot be read $ cat testscript2 #!/usr/bin/env rdmd void main(string[] args){ import std.stdio;

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread Colin via Digitalmars-d-learn
On Saturday, 31 January 2015 at 14:26:45 UTC, RuZzz wrote: The next version, which does not work: https://bpaste.net/show/b9c85de68d07 I really dont understand what your trying to achieve here. Maybe you can articulate it in one post what this class is trying to achieve?

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread Colin via Digitalmars-d-learn
On Saturday, 31 January 2015 at 12:07:23 UTC, RuZzz wrote: How to get amount of digit after point in a double for to get integer from a double? assert(amountAfterPoint(1.456) == 3); assert(amountAfterPoint(0.6) == 5); How about a loop like import std.stdio; void main(){

Re: building a simple json tree

2015-01-15 Thread Colin via Digitalmars-d-learn
On Thursday, 15 January 2015 at 12:50:59 UTC, Rikki Cattermole wrote: On 16/01/2015 1:37 a.m., anonymous wrote: On Thursday, 15 January 2015 at 12:10:09 UTC, Rikki Cattermole wrote: On 16/01/2015 12:16 a.m., anonymous wrote: what's the right syntax for building a JSON tree ? I try to do like

Re: Accessing class with module name as Java's

2015-01-13 Thread Colin via Digitalmars-d-learn
Have the following directory structure? ~/testModule$ find . -print . ./net ./net/http_.d# ** ./net/http ./net/http/Mod1.d ./net/http/Mod2.d ./main.d ** I put the _ here to make it seperate from the net/http directory. Probably, a better solution exists, this was hacked together quickly :)

Re: Accessing class with module name as Java's

2015-01-13 Thread Colin via Digitalmars-d-learn
On Tuesday, 13 January 2015 at 09:22:04 UTC, Colin wrote: Have the following directory structure? ~/testModule$ find . -print . ./net ./net/http_.d# ** ./net/http ./net/http/Mod1.d ./net/http/Mod2.d ./main.d ** I put the _ here to make it seperate from the net/http directory. Probably, a

Re: Compile for other OS's on Windows?

2015-01-05 Thread Colin via Digitalmars-d-learn
On Monday, 5 January 2015 at 15:00:05 UTC, Bauss wrote: On Monday, 5 January 2015 at 12:54:00 UTC, Gary Willoughby wrote: On Monday, 5 January 2015 at 11:49:32 UTC, Bauss wrote: Is it possible to compile for other OS's on Windows using dmd? This is what's known as cross compiling and is not

Re: std.file.readText() extra Line Feed character

2014-12-19 Thread Colin via Digitalmars-d-learn
On Thursday, 18 December 2014 at 22:29:30 UTC, Ali Çehreli wrote: On 12/18/2014 02:51 AM, Colin wrote: vi, and it does indeed have a '\n' at the end of file. Ah, I see. That's a little annoying. It looks like there are ways of dealing with it:

std.file.readText() extra Line Feed character

2014-12-18 Thread Colin via Digitalmars-d-learn
Why does std.file.readText() append a Line Feed char onto the end of the string? I have a file with the following contents in it: Name = Int Other=Float One More = String(Random;) I then have the code: void main(string[] args){ const text = Name = Int

Re: std.file.readText() extra Line Feed character

2014-12-18 Thread Colin via Digitalmars-d-learn
On Thursday, 18 December 2014 at 09:25:47 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 18 Dec 2014 09:18:35 + Colin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Why does std.file.readText() append a Line Feed char onto the end of the string? I have a file

Re: std.file.readText() extra Line Feed character

2014-12-18 Thread Colin via Digitalmars-d-learn
On Thursday, 18 December 2014 at 10:43:32 UTC, yazd wrote: On Thursday, 18 December 2014 at 10:16:38 UTC, Colin wrote: On Thursday, 18 December 2014 at 09:25:47 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 18 Dec 2014 09:18:35 + Colin via Digitalmars-d-learn digitalmars-d-learn

Re: Parsing a date string into a std.datetime.datetime

2014-10-24 Thread Colin via Digitalmars-d-learn
On Thursday, 23 October 2014 at 21:17:23 UTC, Jonathan M Davis wrote: On Thursday, 23 October 2014 at 11:13:26 UTC, Colin wrote: Hi, I'm looking for an easy way to parse a dates into a datetime object. Most of my dates will be of the form: mmm dd, HH:MM AM|PM So like: May 30, 2014

Parsing a date string into a std.datetime.datetime

2014-10-23 Thread Colin via Digitalmars-d-learn
Hi, I'm looking for an easy way to parse a dates into a datetime object. Most of my dates will be of the form: mmm dd, HH:MM AM|PM So like: May 30, 2014 12:12 PM I can easily write a regex or whatever to pull these out of that one format, but it's not guaranteed they'll all be in the

std.algorithm.reduce on an array of structs

2014-09-11 Thread Colin via Digitalmars-d-learn
I have this test code: struct Thing { uint x; } void main(){ uint[] ar1 = [1, 2, 3, 4, 5]; auto min1 = ar1.reduce!((a,b) = a b); writefln(%s, min1); // prints 1 as expected Thing[] ar2 = [Thing(1), Thing(2), Thing(4)]; auto min2 = ar2.reduce!((a,b) = a.x b.x); // -

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Colin via Digitalmars-d-learn
On Thursday, 11 September 2014 at 13:27:39 UTC, Daniel Kozak wrote: On Thursday, 11 September 2014 at 13:06:05 UTC, Colin wrote: I have this test code: struct Thing { uint x; } void main(){ uint[] ar1 = [1, 2, 3, 4, 5]; auto min1 = ar1.reduce!((a,b) = a b); writefln(%s, min1);

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Colin via Digitalmars-d-learn
On Thursday, 11 September 2014 at 14:49:03 UTC, bearophile wrote: Daniel Kozak: You can just use min: import std.stdio, std.algorithm; struct Thing { uint x; alias x this; } alias minimum = reduce!min; void main() { immutable ar1 = [10, 20, 30, 40, 50];

Re: Learning D

2014-08-25 Thread Colin via Digitalmars-d-learn
On Monday, 25 August 2014 at 17:57:54 UTC, Ryan wrote: Anyone know MonoDevelop? Why is the Edit References context menu item missing. I have it at the top (Project-Edit References...) but when I click it nothing happens. Grrr. I couldnt figure it out either tbh (creating dub projects using

Re: Can you explain this?

2014-08-21 Thread Colin via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 20:18:15 UTC, Dicebot wrote: On Wednesday, 20 August 2014 at 20:01:05 UTC, Colin wrote: I see 3 distinct parts playing a role in my confusion: A) The 'is' keyword. What does it do when you have is(expression); http://dlang.org/expression.html#IsExpression It

Can you explain this?

2014-08-20 Thread Colin via Digitalmars-d-learn
Hi, I'm implementing some template checks on some types I'm using in a project, and went to phobos for some indications on how to use them. In std.range, I see this construct quite a bit: template isInputRange(R) { enum bool isInputRange = is(typeof( (inout int = 0) { R

Re: monodevelop mono-d versions

2014-08-01 Thread Colin via Digitalmars-d-learn
On Friday, 1 August 2014 at 09:12:49 UTC, sclytrack wrote: I can't seem to install mono-d. It always seems to want a newer version of MonoDevelop. I'm on Ubuntu 14.04 LTS and it has version 4.0.12 of MonoDevelop. Has anybody else got this to work with this version? I have this file called

Re: monodevelop mono-d versions

2014-08-01 Thread Colin via Digitalmars-d-learn
On Friday, 1 August 2014 at 13:15:25 UTC, Dicebot wrote: On Friday, 1 August 2014 at 09:12:49 UTC, sclytrack wrote: I can't seem to install mono-d. It always seems to want a newer version of MonoDevelop. I'm on Ubuntu 14.04 LTS and it has version 4.0.12 of MonoDevelop. Has anybody else got

Re: Basics of calling C from D

2014-06-11 Thread Colin via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 14:28:49 UTC, belkin wrote: On Wednesday, 11 June 2014 at 14:02:08 UTC, John Colvin wrote: On Wednesday, 11 June 2014 at 13:52:09 UTC, belkin wrote: Example: I have this C function that is compiled into a library //File: factorial.h int factorial(int n);

Re: Basics of calling C from D

2014-06-11 Thread Colin via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 15:14:19 UTC, Colin wrote: On Wednesday, 11 June 2014 at 14:28:49 UTC, belkin wrote: On Wednesday, 11 June 2014 at 14:02:08 UTC, John Colvin wrote: On Wednesday, 11 June 2014 at 13:52:09 UTC, belkin wrote: Example: I have this C function that is compiled into a