Re: Templates for DRY code

2018-01-06 Thread codephantom via Digitalmars-d-learn
On Saturday, 6 January 2018 at 23:32:42 UTC, Paul Backus wrote: On Saturday, 6 January 2018 at 03:38:35 UTC, codephantom wrote: or even.. a.append( s.to!ConvertToElementType(a) ); That's not valid code of course, but the semantics are all contained in that single chunk. This works: import

Re: Templates for DRY code

2018-01-06 Thread codephantom via Digitalmars-d-learn
On Saturday, 6 January 2018 at 03:08:19 UTC, Ali Çehreli wrote: I agree with your point as well. A better name can help there a little. void ConvertAndAppend(T, S)(ref T[] arr, S s) { arr ~= s.to!T; } problem solved ;-) btw. I never thought that I would be able (or actually..willing)

Re: Templates for DRY code

2018-01-05 Thread codephantom via Digitalmars-d-learn
On Saturday, 6 January 2018 at 03:08:19 UTC, Ali Çehreli wrote: It's hard to find a balance between fully explicit and fully automatic. I find myself going back and forth between those two extremes. Ali Code is something that humans write and read (and read far more than write). So I pref

Re: Templates for DRY code

2018-01-05 Thread codephantom via Digitalmars-d-learn
On Saturday, 6 January 2018 at 01:33:11 UTC, Ali Çehreli wrote: One solution is to wrap ~= in a function template. Now the conversion is automatically made to the element type of the array: ... . I think append() could be a part of std.array but I can't find anything like that in Phobos.

Re: Slices and Dynamic Arrays

2017-12-30 Thread codephantom via Digitalmars-d-learn
On Sunday, 31 December 2017 at 03:57:17 UTC, Tony wrote: On Sunday, 31 December 2017 at 03:08:05 UTC, Ivan Trombley wrote: double[] D = [3.14159]; Can you guess what D is? :D It took me a while but I finally came up with "a slice of pi" a slice of pi is irrational.

Re: Finding unsafe line of code

2017-12-29 Thread codephantom via Digitalmars-d-learn
On Friday, 29 December 2017 at 09:38:50 UTC, Vino wrote: Let me re-frame the question with an example, as the Dsafe the below line of code is considered as unsafe(Pointer arithmetic), so let imagine that we have several similar line of code, how do we find such unsafe line, does the compile

Re: Finding unsafe line of code

2017-12-29 Thread codephantom via Digitalmars-d-learn
On Friday, 29 December 2017 at 08:21:10 UTC, Vino wrote: Hi All, Is there a way to find or test which line of a give code is not safe(possible memory corruption). From, Vino.B That question needs to be refined ;-)

Re: No of threads

2017-12-20 Thread codephantom via Digitalmars-d-learn
On Wednesday, 20 December 2017 at 13:41:06 UTC, Vino wrote: Hi Ali, Thank you very much, below are the observations, our program is used to calculate the size of the folders, and we don't see any improvements in the execution speed from the below test, are we missing something. Basically we

Re: DateTime formatting

2017-12-20 Thread codephantom via Digitalmars-d-learn
On Wednesday, 20 December 2017 at 14:30:55 UTC, bauss wrote: I can't seem to find anything in Phobos that allows you to specify custom formats for dates. sometimes it's just better to take control of things yourself ;-) https://forum.dlang.org/post/dmxdtciktpggcxybd...@forum.dlang.org

tuples from text file

2017-12-19 Thread codephantom via Digitalmars-d-learn
so I have a text file containing 3 lines(e.g): 5, "hello", 4.3 "hello", 4.3 "hello", "world", 1, 2, 3, 5.5 Now I want to create tuples from each line. However, (using line 1 as example), I get: Tuple!string("5, \"hello\", 4.3") but I really want: Tuple!(int, string, double)(5, "hello", 4.3)

Re: No of threads

2017-12-19 Thread codephantom via Digitalmars-d-learn
On Tuesday, 19 December 2017 at 10:24:47 UTC, Vino wrote: foreach (d; taskPool.parallel(xxx,20)) : As in Windows 2008 whatever value is set for the parallel the total number of threads does not increase more than 12. So not sure if this is correct, so can any one explain me on same. som

Re: Alias example should supposedly be illegal, but runs fine

2017-12-18 Thread codephantom via Digitalmars-d-learn
On Tuesday, 19 December 2017 at 01:30:07 UTC, Mike Franklin wrote: writeln(S.j); // Error: Instance symbols cannot be used through types. I don't understand why you would say that is a bug. i.e. // import std.stdio; struct S { int j; } void main() { writeln(typeof(S.j

Re: Alias example should supposedly be illegal, but runs fine

2017-12-18 Thread codephantom via Digitalmars-d-learn
On Monday, 18 December 2017 at 23:44:46 UTC, Michael wrote: alias a = s.i; // illegal, s.i is an expression Actually, as I understand it, the example provided in 10. is legal (because it aliases a type), and the example provided in 3. is illegal (because it aliases an expression) perhaps t

Re: Alias example should supposedly be illegal, but runs fine

2017-12-18 Thread codephantom via Digitalmars-d-learn
On Monday, 18 December 2017 at 23:44:46 UTC, Michael wrote: alias a = s.i; // illegal, s.i is an expression alias a = s.i; (this is an alias to a type, since s.i is an int) Hence it is actually 'legal', as far as I understand. i.e... "AliasDeclarations create a symbol that is an alias for

Re: Array Template

2017-12-18 Thread codephantom via Digitalmars-d-learn
On Saturday, 16 December 2017 at 14:14:28 UTC, Vino wrote: Yes, will give a try. From, Vino.B well, this sort of gets there ;-) // - module test; import std.stdio; import std.variant; import std.typecons; import std.conv; import std.string; void main() { Variant[] arr; auto x

Re: Where is sleep()?

2017-12-17 Thread codephantom via Digitalmars-d-learn
On Sunday, 17 December 2017 at 08:32:20 UTC, Ryan David Sheasby wrote: Hey guys. First time poster here. I've searched high and low but can't seem to find a simple sleep/delay/wait/pause function in the core or in phobos. The most recent information I can find about it is this forum post from 1

Re: Scope failure is not preventing application crush in case of uncaught exceptions

2017-12-17 Thread codephantom via Digitalmars-d-learn
On Sunday, 17 December 2017 at 08:26:03 UTC, Jonathan M Davis wrote: assert(0) does indeed turn into a HLT instruction in -release mode (as does any assertion that's known to be false at compile time). It's a special case intended for marking code that's supposed to be unreachable. Without -rel

Re: Scope failure is not preventing application crush in case of uncaught exceptions

2017-12-17 Thread codephantom via Digitalmars-d-learn
On Sunday, 17 December 2017 at 00:10:27 UTC, Anonymouse wrote: If you return inside a scopeguard though, the exception (or error!) is swallowed. https://run.dlang.io/is/GEtQ6D The scope guard will not 'swallow' it, if you use -release mode. Which suggests to me, that assert(0) operates differe

Re: Array Template

2017-12-15 Thread codephantom via Digitalmars-d-learn
On Friday, 15 December 2017 at 17:21:55 UTC, Vino wrote: Hi All, Request your help, Is it possible to an template array something similar as below so that we can insert any type of value(string, int etc). If possible can you provide me a example of how to define such array. Array!(Tuple!(

Re: How to catch line number of exception without catching it ?

2017-12-13 Thread codephantom via Digitalmars-d-learn
On Wednesday, 13 December 2017 at 18:24:09 UTC, Thomas wrote: Or is there a better solution for tracing the error position from root till the branch ? Speaking of tracing exceptions, here's my favourite one .. so far ;-) (I mean come on.. debugging is great fun!) btw. If you compile/run th

Re: Date Formating

2017-12-13 Thread codephantom via Digitalmars-d-learn
On Wednesday, 13 December 2017 at 07:35:40 UTC, Jonathan M Davis wrote: In general, you probably want to cast the SysTime to a DateTime if you're going to do something like that. yes, I would agree ;-) Of course the intention was not really to just format it the same way as Clock.currTime() d

Re: Understanding how dub works

2017-12-12 Thread codephantom via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 22:20:41 UTC, datboi wrote: Hi, I'm learning D (obliviously) learning D in an oblivious manner can be difficult ;-)

Re: Date Formating

2017-12-12 Thread codephantom via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 15:56:59 UTC, Vino wrote: Hi All, Request out help on date formatting, I have code which output the date and time as below , i we need it without the last few numbers.,ie "-MMM-DD HH:MM:SI" Output : 2017-Sep-06 16:06:42.7223837 Required Output : 2017-Sep

Re: Why is there no std.stream anymore?

2017-12-11 Thread codephantom via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 02:15:13 UTC, codephantom wrote: just playing around with this also...in case you only want to read n bytes.. // --- module test; import std.stdio, std.file, std.exception; import std.datetime.stopwatch; void main() { string fil

Re: Why is there no std.stream anymore?

2017-12-11 Thread codephantom via Digitalmars-d-learn
On Monday, 11 December 2017 at 20:51:41 UTC, Jordi Gutiérrez Hermoso wrote: I'd like to read from a file, one byte at a time, without loading the whole file in memory. just playing around with this // module test; import std.stdio, std.file, std.exception; void ma

Re: Sort in return statement

2017-12-09 Thread codephantom via Digitalmars-d-learn
On Saturday, 9 December 2017 at 14:49:28 UTC, Seb wrote: randomSample doesn't sort its returned range Not by design, however, because it samples in the order that the elements appear, *if* those elements are already sorted (whether by design or explicately sorted), then the results of the r

Re: Sort in return statement

2017-12-09 Thread codephantom via Digitalmars-d-learn
On Saturday, 9 December 2017 at 14:18:00 UTC, Seb wrote: Yeah, you are very welcome. It's a bit hidden in the docs: Yes. Thanks for that. After lots of reading, and testing, I managed to get a simple, one liner ;-) (doesn't seem like .release is needed though.) // --- auto draw8Nu

Re: Sort in return statement

2017-12-08 Thread codephantom via Digitalmars-d-learn
On Saturday, 9 December 2017 at 04:31:33 UTC, SimonN wrote: Yes, this works, and your algorithm would even accept arbitary random-access ranges, not merely arrays. Would be nice if I could do it all as a 'one liner': // int[] draw8Numbers() { import std.algorithm.sorting : sor

Re: Sort in return statement

2017-12-08 Thread codephantom via Digitalmars-d-learn
On Saturday, 9 December 2017 at 02:45:35 UTC, rjframe wrote: `sort` returns a SortedRange of ushorts, not an array of ushorts. Make it: ``` import std.array : array; return sort(numbers.take(8)).array; ``` --Ryan That's it! Thanks Ryan.

Re: Check whether a file is empty.

2017-12-08 Thread codephantom via Digitalmars-d-learn
On Friday, 8 December 2017 at 19:13:20 UTC, vino wrote: Hi, The code is same just copy pasted the code form Windows 7 into Windows 2003 and executed, in Windows 7 the log file is of size 0 where as in windows 2003 the log file is of size 2 byte where the log file in both the server is empty.

Sort in return statement

2017-12-08 Thread codephantom via Digitalmars-d-learn
Anyone got ideas on how to get sort() working in the *return* statement? // ushort[] draw8Numbers() { import std.meta : aliasSeqOf; import std.range : iota; ushort[] numbers = [ aliasSeqOf!(iota(1,46)) ]; import std.random : randomShuffle; randomShuffle(numbers)

Re: Optimizing a bigint fibonacci

2017-12-06 Thread codephantom via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 09:59:12 UTC, codephantom wrote: On Wednesday, 6 December 2017 at 09:12:08 UTC, helxi wrote: This is question not directly related to language concepts, it's got more to do with the application. I would appreciate if anyone would point to me how I could optimize

Re: Optimizing a bigint fibonacci

2017-12-06 Thread codephantom via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 09:12:08 UTC, helxi wrote: This is question not directly related to language concepts, it's got more to do with the application. I would appreciate if anyone would point to me how I could optimize this bit of code Compile it with ldc ;-)

Re: lower case only first letter of word

2017-12-06 Thread codephantom via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 13:31:17 UTC, Marc wrote: Does D have a native function to capitalize only the first letter of the word? (I'm asking that so I might avoid reinvent the wheel, which I did sometimes in D) // module test; import std.stdio; void main() { strin

Re: Passing Function as an argument to another Function

2017-12-04 Thread codephantom via Digitalmars-d-learn
On Monday, 4 December 2017 at 11:30:02 UTC, codephantom wrote: On Monday, 4 December 2017 at 11:05:22 UTC, Vino wrote: The original program is as below Error: FunTest.d(52): Error: template FunTest.ptProcessFiles cannot deduce function from argument types !()(string, Array!(Tuple!(string, s

Re: Passing Function as an argument to another Function

2017-12-04 Thread codephantom via Digitalmars-d-learn
On Monday, 4 December 2017 at 11:05:22 UTC, Vino wrote: The original program is as below Error: FunTest.d(52): Error: template FunTest.ptProcessFiles cannot deduce function from argument types !()(string, Array!(Tuple!(string, string)) function(string FFs, string Step, int DirAged), File,

Re: Windows Share Path

2017-12-02 Thread codephantom via Digitalmars-d-learn
On Saturday, 2 December 2017 at 14:23:48 UTC, Vino wrote: Hi, Even tried the Option "Run with Highest Privilege" but no luck. and also tried with option "Configure for : Windows Vista , Windows Server 2008" From, Vino.B You haven't accidently ticked the 'Do not store password' option? Th

Re: Windows Share Path

2017-12-02 Thread codephantom via Digitalmars-d-learn
On Saturday, 2 December 2017 at 07:48:14 UTC, Vino wrote: Even tried with the below code, it works manually but not via Windows scheduler with option "Run whether user is logged on or not" Are you using appropriate credentials in the scheduled task?

Re: scope(exit) and Ctrl-C

2017-12-01 Thread codephantom via Digitalmars-d-learn
On Saturday, 2 December 2017 at 04:28:57 UTC, Wanderer wrote: Thanks! This works. But it seems a little bit suspicions that D's type for handler function has `nothrow` `@nogc` and `@system`. I wonder why is that? During execution of that handler, it make sense to prohibit the allocation of an

Re: scope(exit) and Ctrl-C

2017-12-01 Thread codephantom via Digitalmars-d-learn
On Saturday, 2 December 2017 at 00:41:19 UTC, Wanderer wrote: Is there any method to cleanup on Ctrl-C? // -- import std.stdio; import core.thread; extern(C) void signal(int sig, void function(int)); extern(C) void exit(int exit_val); extern(C) void handle(int

Re: Floating point types default to NaN?

2017-11-29 Thread codephantom via Digitalmars-d-learn
On Friday, 24 November 2017 at 14:30:44 UTC, A Guy With a Question wrote: I would have expected 0 to be the default value. What's the logic behind having them being NaN by default? https://dlang.org/spec/type.html http://www.drdobbs.com/cpp/nans-just-dont-get-no-respect/240005723

Re: Changing the class data underneath some reference

2017-11-29 Thread codephantom via Digitalmars-d-learn
On Thursday, 30 November 2017 at 00:52:25 UTC, codephantom wrote: ... sorry, don't know how the int * got in there ;-) Anyway..who said you can't use pointers in D? Just change: //SomeType bar = foo; SomeType * bar = &foo;

Re: Changing the class data underneath some reference

2017-11-29 Thread codephantom via Digitalmars-d-learn
On Thursday, 30 November 2017 at 00:40:51 UTC, David Colson wrote: Hello all! I'm getting settled into D and I came into a problem. A code sample shows it best: class SomeType { string text; this(string input) {text = input;} } void main() { SomeType foo = new SomeType("Hello");

Re: Email validation

2017-11-28 Thread codephantom via Digitalmars-d-learn
On Tuesday, 28 November 2017 at 18:47:06 UTC, Vino wrote: Hi All, Can you please provide me some example on who to validate an email address as the document dose not have an example for the same Ex: vino.bhee...@hotmail.com Conditions : The domain should contain only "hotmail.com" The ema

Re: Email validation

2017-11-28 Thread codephantom via Digitalmars-d-learn
On Tuesday, 28 November 2017 at 22:42:27 UTC, Mike Wey wrote: isMail only checks the formatting of the email address and optionally if the domain has a MX record. I don't believe MX validation (checkDns) is implemented yet.

Re: Email validation

2017-11-28 Thread codephantom via Digitalmars-d-learn
On Tuesday, 28 November 2017 at 18:47:06 UTC, Vino wrote: Hi All, Can you please provide me some example on who to validate an email address as the document dose not have an example for the same Ex: vino.bhee...@hotmail.com Conditions : The domain should contain only "hotmail.com" The ema

Re: Email validation

2017-11-28 Thread codephantom via Digitalmars-d-learn
On Tuesday, 28 November 2017 at 19:32:40 UTC, Vino wrote: Can you provide me a example, as the link does not have any examples. From, Vino.B btw... yes documentation is an acknowledged issue with regards to phobos...but..that aside...it can also be useful (and wise) to look at the unit t

Re: Is variable void?

2017-11-27 Thread codephantom via Digitalmars-d-learn
On Tuesday, 28 November 2017 at 05:10:39 UTC, bauss wrote: null != void also...void is a completely useless concept for initialisation. what can you determine about the nothingness of void? ... nothing. writeln(typeof(void).stringof); // ?? what do I know now? nothing. vs Nullable!int x;

Re: Is variable void?

2017-11-27 Thread codephantom via Digitalmars-d-learn
On Tuesday, 28 November 2017 at 05:10:39 UTC, bauss wrote: null != void "initialized or not?" != void

Re: Is variable void?

2017-11-26 Thread codephantom via Digitalmars-d-learn
On Saturday, 25 November 2017 at 15:34:21 UTC, John Chapman wrote: Is there any way of determining whether a variable has been initialized or not? For example, if something is declared like this: int x = void; can I check if it's void before I use it, say, in a function it's been passed to

Re: betterC and noboundscheck

2017-11-23 Thread codephantom via Digitalmars-d-learn
On Friday, 24 November 2017 at 05:01:17 UTC, Basile B. wrote: On Friday, 24 November 2017 at 00:17:31 UTC, codephantom wrote: On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote: If I add -noboundscheck flag all works fine. dmd version is 2.076.1 Why -betterC flag not 'include' -nobo

Re: betterC and noboundscheck

2017-11-23 Thread codephantom via Digitalmars-d-learn
On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote: If I add -noboundscheck flag all works fine. dmd version is 2.076.1 Why -betterC flag not 'include' -noboundscheck flag? It's bug or in some cases it's useful? Interestingly, ldc2 will compile this ok, without the -noboundscheck

Re: One liner alternatives for initing and pushing some values into array

2017-11-20 Thread codephantom via Digitalmars-d-learn
On Monday, 20 November 2017 at 08:37:32 UTC, kerdemdemir wrote: bool boolList[] = { a, b, c }; D alternative(at least my D alternative) seem long. Is there any better way for initialing and pushing values at the same time. Erdem Your use of the appender method suggest to me you want to be

Re: ESR on post-C landscape

2017-11-16 Thread codephantom via Digitalmars-d-learn
On Thursday, 16 November 2017 at 11:52:45 UTC, Ola Fosheim Grostad wrote: Uhm, no? What do you mean by 'primary focus of program design' and in which context? I the context that, this is specifically what Stroustrup says in his book (The Design and Evolution of C++ 1994) "Simula's class

Re: ESR on post-C landscape

2017-11-16 Thread codephantom via Digitalmars-d-learn
On Thursday, 16 November 2017 at 06:35:30 UTC, Ola Fosheim Grostad wrote: No, classes is a powerful modelling primitive. C++ got that right. C++ is also fairly uniform because of it. Yes, I agree that classes are a powerful modelling primitive, but my point was that Stroustrup made classes the

Re: ESR on post-C landscape

2017-11-15 Thread codephantom via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 11:55:17 UTC, codephantom wrote: The reason he can dismiss D, so easily, is because of his starting premise that C is flawed. As soon as you begin with that premise, you justify searching for C's replacement, which makes it difficult to envsion something like D.

Re: ESR on post-C landscape

2017-11-15 Thread codephantom via Digitalmars-d-learn
On Wednesday, 15 November 2017 at 09:26:49 UTC, Ola Fosheim Grøstad wrote: I don't think Go is much affected by the corporate… Umm "We made the language to help make google more productive and helpful internally" - Rob Pike https://www.youtube.com/watch?v=sln-gJaURzk 2min:55sec To be

Re: ESR on post-C landscape

2017-11-14 Thread codephantom via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 16:38:58 UTC, Ola Fosheim Grostad wrote: It [C]is flawed... ESR got that right, not sure how anyone can disagree. Well I 'can' disagree ;-) Is a scalpel flawed because someone tried to use it to screw in a screw? Languages are just part of an evolutionary cha

Re: ESR on post-C landscape

2017-11-14 Thread codephantom via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 04:31:43 UTC, Laeeth Isharc wrote: He mentions D, a bit dismissively. http://esr.ibiblio.org/?p=7724&cpage=1#comment-1912717 The reason he can dismiss D, so easily, is because of his starting premise that C is flawed. As soon as you begin with that premise, you

Re: core file

2017-11-13 Thread codephantom via Digitalmars-d-learn
On Monday, 13 November 2017 at 06:25:20 UTC, Tony wrote: I am on Ubuntu 16.04. Thanks, I didn't know that "producing a core file" was configurable, and it appears that it isn't. ok. that's because Ubuntu is not (by default) setup for developers. But you can enable core dump for your executab

Re: core file

2017-11-12 Thread codephantom via Digitalmars-d-learn
On Monday, 13 November 2017 at 05:01:18 UTC, Tony wrote: I am getting the message from my program execution: "Segmentation fault (core dumped)" But I don't see a core file in the current directory or in my home directory. Is there one somewhere? Would I be able to do anything meaningful with

Re: std.functional.compose compilation error

2017-11-08 Thread codephantom via Digitalmars-d-learn
On Thursday, 9 November 2017 at 04:58:19 UTC, Chuck Allison wrote: As others have said, rename the .d file, since files are considered modules. I have since changed my notes to reflect this change. Sorry for the confusion. Chuck Allison When coming to a new language I tend to write lots of

Re: How do i find a list of the methods Object implements, or maybe just locate the 'write' method?

2017-11-08 Thread codephantom via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 12:48:41 UTC, codephantom wrote: Apparently its a bug in LDC (but personally, it's a bug I like). mistyped: I meant a bug in GDC, not LDC.

Re: How do i find a list of the methods Object implements, or maybe just locate the 'write' method?

2017-11-08 Thread codephantom via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 12:17:14 UTC, bauss wrote: That's because the module name becomes `write` then. yeah I knew that. I was trying to demonstrate how (when the module name is 'write'), then the compiler is ok with: o.write; but not: write(o); even though semantically they a

Re: How do i find a list of the methods Object implements, or maybe just locate the 'write' method?

2017-11-07 Thread codephantom via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 03:33:08 UTC, bauss wrote: -- Compiles fine with DMD: https://dpaste.dzfl.pl/95b896aa242f ahh.. that site saves it with some random temporary file name I assume. If it saved it as writ

Re: How do i find a list of the methods Object implements, or maybe just locate the 'write' method?

2017-11-07 Thread codephantom via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 03:33:08 UTC, bauss wrote: -- Compiles fine with DMD: https://dpaste.dzfl.pl/95b896aa242f you saved it as?: write.d you didn't add in a module statement? and it compiled??

Re: How do i find a list of the methods Object implements, or maybe just locate the 'write' method?

2017-11-07 Thread codephantom via Digitalmars-d-learn
On Tuesday, 7 November 2017 at 21:32:26 UTC, Adam D. Ruppe wrote: On Tuesday, 7 November 2017 at 21:25:00 UTC, dan wrote: I looked in my distribution's object.d (debian stretch, gdc, in Did you import std.stdio in the file? If so, it is calling the std.stdio.write on the object (this is call

Re: if (int bar = .. bug or some thing

2017-10-30 Thread codephantom via Digitalmars-d-learn
On Tuesday, 31 October 2017 at 04:27:27 UTC, Joel wrote: Ok, thanks guys. why not throw in some UFCS too...just because you can ;-) import std.stdio; void main() { int foo; if (foo.bar != 0) // would be nice if I could do: (int foo.bar != 0) { throw new Exception("foo.b

std.format and floating point issue

2017-10-29 Thread codephantom via Digitalmars-d-learn
Can anyone help me to understand why the format in the second writeln below, does not format the output with commas? void main() { import std.stdio, std.format; writeln( format("%,.1f", 84543432.951172) ); // 84,543,433.0 writeln( format("%,.0f", 84

Re: Just starting with D (linking with C++)

2017-10-27 Thread codephantom via Digitalmars-d-learn
On Friday, 27 October 2017 at 17:14:20 UTC, sivakon wrote: I want to use C++ libraries for machine learning and deep learning. How do I add C++ libraries to my d code. on FreeBSD, I use: for C static binding: -- clang -c sample.c dmd -L-lc foo.d sample.o or ldc -L-lc foo.d