Re: Functional Programming in D

2019-10-10 Thread Russel Winder via Digitalmars-d-learn
On Wed, 2019-10-09 at 11:12 -0700, H. S. Teoh via Digitalmars-d-learn wrote: […] > Actually, std.functional is somewhat of a misnomer. It mostly deals with > higher-order functions, i.e., functions that return functions, currying, > that sort of thing. These are part of functional programming,

Re: Functional Programming in D

2019-10-10 Thread Tobias Pankrath via Digitalmars-d-learn
On Wednesday, 9 October 2019 at 18:57:01 UTC, SrMordred wrote: https://garden.dlang.io/ This should be more prominent. Very nice.

Re: Functional Programming in D

2019-10-10 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Oct 10, 2019 at 09:59:49AM +0100, Russel Winder via Digitalmars-d-learn wrote: > On Wed, 2019-10-09 at 11:12 -0700, H. S. Teoh via Digitalmars-d-learn wrote: > […] > > Actually, std.functional is somewhat of a misnomer. It mostly deals > > with higher-order functions, i.e., functions that

Re: Functional Programming in D

2019-10-10 Thread Russel Winder via Digitalmars-d-learn
On Thu, 2019-10-10 at 03:08 -0700, H. S. Teoh via Digitalmars-d-learn wrote: […] > Note this is why I wrote "functional-style programming" w.r.t. D, rather > than "functional programming". Clearly, what D has isn't "real" > functional programming in the strict sense, but it does share similar >

How to do IPC using Unix Domain Socket?

2019-10-10 Thread Hossain Adnan via Digitalmars-d-learn
Here I have a program that wants to 1. detect whether if it's the only instance 1.1. it does that by trying to create a Unix Domain Socket and trying to binding it to a specific address. 2. if a duplicate program is not running, establish an UDS and then listen to the socket.

Re: How to do IPC using Unix Domain Socket?

2019-10-10 Thread Hossain Adnan via Digitalmars-d-learn
On Thursday, 10 October 2019 at 12:30:25 UTC, Hossain Adnan wrote: Here I have a program that wants to 1. detect whether if it's the only instance 1.1. it does that by trying to create a Unix Domain Socket and trying to binding it to a specific address. [...] If it helps explaining

C#'s 'is' equivalent in D

2019-10-10 Thread Just Dave via Digitalmars-d-learn
In C# you can do something like: if (obj is Person) { var person = obj as Person; // do stuff with person... } where you can check the type of an object prior to casting. Does D have a similar mechanism? It's so widely useful in the C# realm that they even added

Re: Functional Programming in D

2019-10-10 Thread bachmeier via Digitalmars-d-learn
On Thursday, 10 October 2019 at 08:59:49 UTC, Russel Winder wrote: I feel that it is best to leave functional programming to functional programming language, e.g. Haskell, Scheme, etc. rather than try to do functional programming in imperative languages, e.g. Java, C++, Rust, D. The reason is

Re: C#'s 'is' equivalent in D

2019-10-10 Thread jmh530 via Digitalmars-d-learn
On Thursday, 10 October 2019 at 16:33:47 UTC, H. S. Teoh wrote: On Thu, Oct 10, 2019 at 03:58:02PM +, jmh530 via Digitalmars-d-learn wrote: On Thursday, 10 October 2019 at 15:47:58 UTC, Just Dave wrote: > In C# you can do something like: > > > if (obj is Person) > { > var

Re: Functional Programming in D

2019-10-10 Thread Bienlein via Digitalmars-d-learn
On Thursday, 10 October 2019 at 10:08:14 UTC, H. S. Teoh wrote: On Thu, Oct 10, 2019 at 09:59:49AM +0100, Russel Winder via Digitalmars-d-learn wrote: On Wed, 2019-10-09 at 11:12 -0700, H. S. Teoh via Digitalmars-d-learn wrote: […] > Actually, std.functional is somewhat of a misnomer. It >

Re: C#'s 'is' equivalent in D

2019-10-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, October 10, 2019 9:47:58 AM MDT Just Dave via Digitalmars-d- learn wrote: > In C# you can do something like: > > > if (obj is Person) > { > var person = obj as Person; > // do stuff with person... > } > > where you can check the type of an object prior

Re: Functional Programming in D

2019-10-10 Thread bachmeier via Digitalmars-d-learn
On Thursday, 10 October 2019 at 10:08:14 UTC, H. S. Teoh wrote: On Thu, Oct 10, 2019 at 09:59:49AM +0100, Russel Winder via Digitalmars-d-learn wrote: On Wed, 2019-10-09 at 11:12 -0700, H. S. Teoh via Digitalmars-d-learn wrote: […] > Actually, std.functional is somewhat of a misnomer. It >

Re: C#'s 'is' equivalent in D

2019-10-10 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Oct 10, 2019 at 03:58:02PM +, jmh530 via Digitalmars-d-learn wrote: > On Thursday, 10 October 2019 at 15:47:58 UTC, Just Dave wrote: > > In C# you can do something like: > > > > > > if (obj is Person) > > { > > var person = obj as Person; > > // do stuff with

Re: formatting a float or double in a string with all significant digits kept

2019-10-10 Thread dan via Digitalmars-d-learn
On Wednesday, 9 October 2019 at 10:54:49 UTC, David Briant wrote: On Tuesday, 8 October 2019 at 20:37:03 UTC, dan wrote: I have a double precision number that i would like to print all significant digits of, but no more than what are actually present in the number. Or more exactly, i want to

Re: How to do IPC using Unix Domain Socket?

2019-10-10 Thread Hossain Adnan via Digitalmars-d-learn
On Thursday, 10 October 2019 at 12:30:25 UTC, Hossain Adnan wrote: Here I have a program that wants to 1. detect whether if it's the only instance 1.1. it does that by trying to create a Unix Domain Socket and trying to binding it to a specific address. 2. if a duplicate program is not

Difference between template and mixin template

2019-10-10 Thread Just Dave via Digitalmars-d-learn
I'm trying to get my head around mixing templates. I'm using it as kind of a replacement for class inheritance as it seems to fit better composition over inheritance. So I do something like: mixin template NumberTemplate() { private: int number = 0; public: int

Re: C#'s 'is' equivalent in D

2019-10-10 Thread drug via Digitalmars-d-learn
On 10/10/19 6:47 PM, Just Dave wrote: In C# you can do something like:     if (obj is Person)     {     var person = obj as Person;     // do stuff with person...     } where you can check the type of an object prior to casting. Does D have a similar mechanism? It's so widely

Re: C#'s 'is' equivalent in D

2019-10-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 10 October 2019 at 15:47:58 UTC, Just Dave wrote: if (obj is Person person) Looks the same as D's if(auto person = cast(Person) obj) { // use person in here } else { // it was some other type }

Re: C#'s 'is' equivalent in D

2019-10-10 Thread Just Dave via Digitalmars-d-learn
Even though static solutions would be more performance minded, I'd actually prefer to see the runtime equivalent so I don't have to rethink how I think as performance isn't really my major concern right now.

Re: C#'s 'is' equivalent in D

2019-10-10 Thread jmh530 via Digitalmars-d-learn
On Thursday, 10 October 2019 at 15:47:58 UTC, Just Dave wrote: In C# you can do something like: if (obj is Person) { var person = obj as Person; // do stuff with person... } where you can check the type of an object prior to casting. Does D have a similar

Re: C#'s 'is' equivalent in D

2019-10-10 Thread Just Dave via Digitalmars-d-learn
On Thursday, 10 October 2019 at 15:53:20 UTC, Adam D. Ruppe wrote: On Thursday, 10 October 2019 at 15:47:58 UTC, Just Dave wrote: if (obj is Person person) Looks the same as D's if(auto person = cast(Person) obj) { // use person in here } else { // it was some other type }

Re: Difference between template and mixin template

2019-10-10 Thread Just Dave via Digitalmars-d-learn
On Thursday, 10 October 2019 at 15:56:36 UTC, Just Dave wrote: I'm trying to get my head around mixing templates. I'm using it as kind of a replacement for class inheritance as it seems to fit better composition over inheritance. So I do something like: mixin template NumberTemplate()

_getmaxstdio / _setmaxstdio

2019-10-10 Thread Damian via Digitalmars-d-learn
Missing _getmaxstdio / _setmaxstdio? I'd like to try and increase the limit of open files without resorting to Windows API, is it possible or will I have to resort to the WinAPI to achieve this? Thanks Damian

Re: formatting a float or double in a string with all significant digits kept

2019-10-10 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Oct 10, 2019 at 09:13:05PM +, Jon Degenhardt via Digitalmars-d-learn wrote: > On Thursday, 10 October 2019 at 17:12:25 UTC, dan wrote: > > Thanks also berni44 for the information about the dig attribute, Jon > > for the neat packaging into one line using the attribute on the > > type.

How can I make a program which uses all cores and 100% of cpu power?

2019-10-10 Thread Murilo via Digitalmars-d-learn
I have started working with neural networks and for that I need a lot of computing power but the programs I make only use around 30% of the cpu, or at least that is what Task Manager tells me. How can I make it use all 4 cores of my AMD FX-4300 and how can I make it use 100% of it?

Re: D man pages

2019-10-10 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 10 October 2019 at 19:26:36 UTC, Daniel Kozak wrote: On Thursday, 10 October 2019 at 19:25:22 UTC, Daniel Kozak wrote: On Thursday, 10 October 2019 at 19:21:06 UTC, Daniel Kozak wrote: On Thursday, 10 October 2019 at 19:19:42 UTC, Daniel Kozak wrote: On Thursday, 10 October 2019

Re: D man pages

2019-10-10 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 10 October 2019 at 18:52:32 UTC, Jarek wrote: On Monday, 23 September 2019 at 12:31:16 UTC, Adam D. Ruppe wrote: [...] Hello, thanks for reply. This is my first dlang work: import std.stdio; import std.conv; import core.sys.posix.dirent; [...] You should use fromStringZ:

Undefined symbol: _dyld_enumerate_tlv_storage (OSX)

2019-10-10 Thread Robert M. Münch via Digitalmars-d-learn
I have two project I want to compile and both times get this error: Undefined symbols for architecture x86_64: "_dyld_enumerate_tlv_storage", referenced from: __d_dyld_getTLSRange in libphobos2.a(osx_tls.o) I'm wondering where this comes from as I didn't see it in the past. Any idea? --

Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)

2019-10-10 Thread Daniel Kozak via Digitalmars-d-learn
What dmd version? https://issues.dlang.org/show_bug.cgi?id=20019 On Thu, Oct 10, 2019 at 8:15 PM Robert M. Münch via Digitalmars-d-learn wrote: > > I have two project I want to compile and both times get this error: > > Undefined symbols for architecture x86_64: >

Re: D man pages

2019-10-10 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 10 October 2019 at 19:19:42 UTC, Daniel Kozak wrote: On Thursday, 10 October 2019 at 18:52:32 UTC, Jarek wrote: On Monday, 23 September 2019 at 12:31:16 UTC, Adam D. Ruppe wrote: [...] Hello, thanks for reply. This is my first dlang work: import std.stdio; import std.conv;

Re: D man pages

2019-10-10 Thread Jarek via Digitalmars-d-learn
On Monday, 23 September 2019 at 12:31:16 UTC, Adam D. Ruppe wrote: On Monday, 23 September 2019 at 06:06:05 UTC, Jarek wrote: I have the same question. Where to find something similar to man pages from C? They are the same functions, so the idea is you can just use the C man pages directly.

Re: D man pages

2019-10-10 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 10 October 2019 at 19:25:22 UTC, Daniel Kozak wrote: On Thursday, 10 October 2019 at 19:21:06 UTC, Daniel Kozak wrote: On Thursday, 10 October 2019 at 19:19:42 UTC, Daniel Kozak wrote: On Thursday, 10 October 2019 at 18:52:32 UTC, Jarek wrote: On Monday, 23 September 2019 at

Re: D man pages

2019-10-10 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 10 October 2019 at 19:21:06 UTC, Daniel Kozak wrote: On Thursday, 10 October 2019 at 19:19:42 UTC, Daniel Kozak wrote: On Thursday, 10 October 2019 at 18:52:32 UTC, Jarek wrote: On Monday, 23 September 2019 at 12:31:16 UTC, Adam D. Ruppe wrote: [...] Hello, thanks for reply.

Re: formatting a float or double in a string with all significant digits kept

2019-10-10 Thread Jon Degenhardt via Digitalmars-d-learn
On Thursday, 10 October 2019 at 17:12:25 UTC, dan wrote: Thanks also berni44 for the information about the dig attribute, Jon for the neat packaging into one line using the attribute on the type. Unfortunately, the version of gdc that comes with the version of debian that i am using does not

Re: How can I make a program which uses all cores and 100% of cpu power?

2019-10-10 Thread Daniel Kozak via Digitalmars-d-learn
On Fri, Oct 11, 2019 at 2:45 AM Murilo via Digitalmars-d-learn wrote: > > I have started working with neural networks and for that I need a > lot of computing power but the programs I make only use around > 30% of the cpu, or at least that is what Task Manager tells me. > How can I make it use

Re: formatting a float or double in a string with all significant digits kept

2019-10-10 Thread dan via Digitalmars-d-learn
On Thursday, 10 October 2019 at 22:44:05 UTC, H. S. Teoh wrote: On Thu, Oct 10, 2019 at 09:13:05PM +, Jon Degenhardt via Digitalmars-d-learn wrote: On Thursday, 10 October 2019 at 17:12:25 UTC, dan wrote: > Thanks also berni44 for the information about the dig > attribute, Jon > for the

Re: How can I make a program which uses all cores and 100% of cpu power?

2019-10-10 Thread Daniel Kozak via Digitalmars-d-learn
On Fri, Oct 11, 2019 at 6:58 AM Daniel Kozak wrote: > > so can stress your CPU. can't