Re: String Comparison Operator

2017-04-30 Thread Xinok via Digitalmars-d-learn
On Sunday, 30 April 2017 at 19:05:18 UTC, bauss wrote: On Sunday, 30 April 2017 at 16:15:41 UTC, Xinok wrote: On Sunday, 30 April 2017 at 15:31:39 UTC, Jolly James wrote: Is there a String Comparison Operator in D? Yeah, just the usual comparison operators: "abc" == "abc" "abc" != "ABC" ~

Re: String Comparison Operator

2017-04-30 Thread Xinok via Digitalmars-d-learn
On Sunday, 30 April 2017 at 15:31:39 UTC, Jolly James wrote: Is there a String Comparison Operator in D? Yeah, just the usual comparison operators: "abc" == "abc" "abc" != "ABC" ~ is for string concatenation, i.e.: "abc" ~ "def" == "abcdef"

Re: Interpolated strings

2017-04-15 Thread Xinok via Digitalmars-d
On Saturday, 15 April 2017 at 20:04:13 UTC, Jonas Drewsen wrote: Hi all I shared my thoughts on such a feature just a couple weeks ago: https://forum.dlang.org/post/oedeijdewmhazaqaz...@forum.dlang.org

Re: [OT] ISO C++ 17 changes

2017-04-04 Thread Xinok via Digitalmars-d
On Tuesday, 4 April 2017 at 02:43:26 UTC, evilrat wrote: String interpolation would be nice too, it would really help with readability! This really isn't in the spirit of D and is better left to library functions which give the user far more power and flexibility. Incorporating such a

Re: Why double not? (!!)

2016-11-18 Thread Xinok via Digitalmars-d-learn
On Saturday, 19 November 2016 at 03:52:02 UTC, Ryan wrote: Why do I see double `not` operators sometimes in D code? An example it the last post of this thread. http://forum.dlang.org/thread/ktlpnikvdwgbvfaam...@forum.dlang.org import core.sys.windows.windows : GetConsoleCP; bool hasConsole =

Re: Fallback 'catch-all' template functions

2016-09-02 Thread Xinok via Digitalmars-d
On Thursday, 1 September 2016 at 05:37:50 UTC, Manu wrote: So, consider a set of overloads: void f(T)(T t) if(isSomething!T) {} void f(T)(T t) if(isSomethingElse!T) {} void f(T)(T t) {} I have a recurring problem where I need a fallback function like the bottom one, which should be used

Re: IPFS

2016-08-14 Thread Xinok via Digitalmars-d
On Sunday, 14 August 2016 at 21:21:25 UTC, Nordlöw wrote: I advice you all to read about IPFS at https://ipfs.io/ ... It sounds interesting but what concerns me is the lack of attention given to privacy and anonymity, two things that should be core values and top priorities for any protocol

Re: pure D JPEG decoder, with progressive JPEG support, public domain

2016-06-17 Thread Xinok via Digitalmars-d-announce
On Friday, 17 June 2016 at 22:15:47 UTC, ketmar wrote: i put it under unlicense[1], as some other works of the same author is using it, and it is basically the same PD. [1] http://unlicense.org/ Unfortunately, using unlicense is just as problematic as using public domain:

Re: Idea: swap with multiple arguments

2016-05-24 Thread Xinok via Digitalmars-d
On Tuesday, 24 May 2016 at 18:51:32 UTC, Andrei Alexandrescu wrote: On 05/24/2016 02:48 PM, Xinok wrote: BTW, Phobos already has a function called bringToFront which can rotate/roll ranges but the interface is a bit different compared to other languages.

Re: Idea: swap with multiple arguments

2016-05-24 Thread Xinok via Digitalmars-d
On Monday, 23 May 2016 at 20:01:08 UTC, Andrei Alexandrescu wrote: ... I wish to make a different point which is more general regarding ideas like these. I see a lot of proposals to add this or that to the standard library and a lot of debate pursues. One point I've never seen mentioned

Re: Idea: swap with multiple arguments

2016-05-23 Thread Xinok via Digitalmars-d
On Monday, 23 May 2016 at 20:01:08 UTC, Andrei Alexandrescu wrote: So swap(a, b) swaps the contents of a and b. This could be easily generalized to multiple arguments such that swap(a1, a2, ..., an) arranges things such that a1 gets an, a2 gets a1, a3 gets a2, etc. I do know applications for

Re: Project: better partition

2016-05-22 Thread Xinok via Digitalmars-d
On Wednesday, 18 May 2016 at 19:54:19 UTC, Andrei Alexandrescu wrote: ... No worries. Please take anything you need from there for your code, make it better, and contribute it back to the stdlib! -- Andrei As it turns out, easier said than done. I've been thinking about it for a few days

Re: Project: better partition

2016-05-18 Thread Xinok via Digitalmars-d
On Tuesday, 17 May 2016 at 19:27:22 UTC, Xinok wrote: On Tuesday, 17 May 2016 at 17:31:47 UTC, Andrei Alexandrescu wrote: We should take advantage of the improved partition code I discussed at ACCU. Also there's a person on

Re: Project: better partition

2016-05-17 Thread Xinok via Digitalmars-d
On Tuesday, 17 May 2016 at 17:31:47 UTC, Andrei Alexandrescu wrote: We should take advantage of the improved partition code I discussed at ACCU. Also there's a person on https://www.reddit.com/r/programming/comments/4jlkhv/accu_2016_keynote_by_andrei_alexandrescu/ discussing a simpler algorithm

Re: D mentioned and criticized

2016-05-16 Thread Xinok via Digitalmars-d
On Monday, 16 May 2016 at 18:25:23 UTC, Chris wrote: I had a look at Loci, more specifically the language goals[1]: ... I've been skimming through the docs and found one mention of D: http://loci-lang.org/Exceptions.html#scope-exit-block It seems to me that Loci is not a very "inspired"

Re: Always false float comparisons

2016-05-09 Thread Xinok via Digitalmars-d
On Monday, 9 May 2016 at 20:14:36 UTC, Walter Bright wrote: On 5/9/2016 11:37 AM, Xinok wrote: All of these scenarios are capable of producing "incorrect" results, are a source of discrete bugs (often corner cases that we failed to consider and test), and can be hard to detect. It's about time

Re: Always false float comparisons

2016-05-09 Thread Xinok via Digitalmars-d
On Monday, 9 May 2016 at 18:51:58 UTC, tsbockman wrote: On Monday, 9 May 2016 at 18:37:10 UTC, Xinok wrote: ... (3) Generalize it to all comparisons as well, including < and ... (3) Makes no sense though; inequalities with mixed floating-point types are perfectly safe. (Well, as safe as any

Re: Always false float comparisons

2016-05-09 Thread Xinok via Digitalmars-d
On Monday, 9 May 2016 at 09:10:19 UTC, Walter Bright wrote: Don Clugston pointed out in his DConf 2016 talk that: float f = 1.30; assert(f == 1.30); will always be false since 1.30 is not representable as a float. However, float f = 1.30; assert(f == cast(float)1.30); will

Discrete semantics of lambda expressions

2016-05-02 Thread Xinok via Digitalmars-d
D has a few ways of writing lambda expressions / anonymous functions: x => doSomething() { doSomething(); } (){ doSomething(); } While the flexibility is great, there's a hidden issue for those programmers who come from different languages and are used to writing: x => {

Re: Checking if an Integer is an Exact Binary Power

2016-04-26 Thread Xinok via Digitalmars-d
On Monday, 25 April 2016 at 15:35:14 UTC, Dominikus Dittes Scherkl wrote: On Monday, 25 April 2016 at 15:27:02 UTC, Xinok wrote: Brute force. http://dpaste.dzfl.pl/882d7cdc5f74 Yeah. And your test spares the failed case int.min (0x8000), because in this case x & -x is negative, but of

Re: Checking if an Integer is an Exact Binary Power

2016-04-25 Thread Xinok via Digitalmars-d
On Monday, 25 April 2016 at 12:56:27 UTC, Andrei Alexandrescu wrote: On 4/25/16 6:42 AM, Solomon E wrote: On Monday, 25 April 2016 at 05:35:12 UTC, Andrei Alexandrescu wrote: With gdc https://godbolt.org/g/jcU4np isPow2B is the winner (shortest code, simplest instructions). -- Andrei I

Re: Checking if an Integer is an Exact Binary Power

2016-04-24 Thread Xinok via Digitalmars-d
On Sunday, 24 April 2016 at 23:17:53 UTC, David Nadlinger wrote: On Sunday, 24 April 2016 at 23:00:56 UTC, Temtaime wrote: Please no cmp. Just bool isPowerOf2(uint x) { return x && !(x & (x - 1)); } You do realise that this will (typically) emit a branch? — David I compiled using dmd -O

Re: Checking if an Integer is an Exact Binary Power

2016-04-24 Thread Xinok via Digitalmars-d
On Monday, 25 April 2016 at 01:17:48 UTC, Xinok wrote: ... Sorry, didn't mean to say David's solution. Too many edits. >_<

Re: @nogc inconsistent for array comparison depending on mutability of elements

2016-04-08 Thread Xinok via Digitalmars-d-learn
On Friday, 8 April 2016 at 10:15:10 UTC, Dicebot wrote: On Friday, 8 April 2016 at 09:56:41 UTC, Nick Treleaven wrote: Semantically, array literals are always allocated on the heap. In this case, the optimizer can obviously place the array on the stack or even make it static/global. So @nogc

Re: @nogc inconsistent for array comparison depending on mutability of elements

2016-04-07 Thread Xinok via Digitalmars-d-learn
On Friday, 8 April 2016 at 01:36:18 UTC, rcorre wrote: @nogc unittest { int[2] a = [1, 2]; assert(a == [1, 2]); // OK immutable(int)[2] b = [1, 2]; assert(b == [1, 2]); // fail: array literal may cause allocation } Is there any logic behind allowing the comparison with `a`

Re: Better Phobos contribution guide

2016-03-25 Thread Xinok via Digitalmars-d
On Friday, 25 March 2016 at 07:14:52 UTC, Seb wrote: - dont add @nogc, @pure, @safe attributes yourself - let the compiler infer it! I'd argue this is only applicable to some functions, not all. In particular, for non-templated functions, - avoid to use `auto` as return type I understand

Re: Some crazy ideas from a high level perspective

2016-03-22 Thread Xinok via Digitalmars-d
On Tuesday, 22 March 2016 at 14:08:55 UTC, _d0s_ wrote: Idea1: a general interface to describe n-dimensional matrices Perhaps this is what you're looking for? https://dlang.org/phobos/std_experimental_ndslice.html

Re: Defer in D

2016-03-21 Thread Xinok via Digitalmars-d
On Monday, 21 March 2016 at 17:46:05 UTC, Dmitry Olshansky wrote: ... The main use case in Go that needs it specifically as a function level primitive is this: files := []File{} for i := paths { files[i], err := os.Open(paths[i]) if err != nil { return

Defer in D

2016-03-19 Thread Xinok via Digitalmars-d
I stumbled upon an example demonstrating defer in Go which I thought was interesting. Defer is similar to scope in D except they're called at end of function rather than end of scope; you can queue multiple defer calls by writing them inside of a loop. This implies that it internally builds a

Re: Suggested Change to Contract Syntax

2016-03-10 Thread Xinok via Digitalmars-d
On Thursday, 10 March 2016 at 21:07:09 UTC, FatalCatharsis wrote: I am very new to D so I apologize if I'm very uninformed. I'm learning D by porting a big (awful) c++ project to D so that I may take advantage of all the lovely testing and QA features. I am currently moving a class over that I

Re: How to sort a range

2016-03-09 Thread Xinok via Digitalmars-d-learn
On Wednesday, 9 March 2016 at 15:39:55 UTC, rcorre wrote: Still curious as to why it fails; maybe the range is getting copied at some point? I guess I need to step through it. That's my suspicion as well. It seems that OnlyResult is pass-by-value so every time it gets passed to another

Re: Uniform Function Call Syntax?

2016-03-06 Thread Xinok via Digitalmars-d
On Sunday, 6 March 2016 at 07:45:58 UTC, Ola Fosheim Grøstad wrote: I think it would be better idea to just add the ability to add unicode operators, and to avoid precedence issues one could just require them to use parentheses. That way you could define opCustom"•" and use it as: ( point1 •

Re: [OT] Some neat ideas from the Kotlin language

2016-02-23 Thread Xinok via Digitalmars-d
On Tuesday, 23 February 2016 at 19:43:43 UTC, rsw0x wrote: ... How does this differ from the example I gave where the branch is only taken if the pointer is non-null? D doesn't prevent you from dereferencing a null pointer whereas these scenarios should be impossible in Kotlin as well as

Re: [OT] Some neat ideas from the Kotlin language

2016-02-23 Thread Xinok via Digitalmars-d
On Tuesday, 23 February 2016 at 07:18:09 UTC, rsw0x wrote: On Tuesday, 23 February 2016 at 06:49:46 UTC, Tobias Müller wrote: OTOH in the examples in Kotlin/Rust the variable 'var' changes its type from 'int?' to plain 'int'. In Kotlin this is done with static analysis, in Rust with rebinding

Re: [OT] Some neat ideas from the Kotlin language

2016-02-20 Thread Xinok via Digitalmars-d
On Saturday, 20 February 2016 at 09:40:40 UTC, Tobias Müller wrote: ... It's not much more verbose but more explicit. Changing the type of a variable based on static analysis is just advanced obfuscation. It hurts readability and the gain is questionable. At least it only works for nullable

Re: Official compiler

2016-02-17 Thread Xinok via Digitalmars-d
On Wednesday, 17 February 2016 at 22:57:20 UTC, Márcio Martins wrote: I was reading the other thread "Speed kills" and was wondering if there is any practical reason why DMD is the official compiler? ... I pretty much asked this same question a little over a year ago. Thread is here:

Re: How to force evaluation of range?

2016-02-12 Thread Xinok via Digitalmars-d-learn
On Friday, 12 February 2016 at 20:43:24 UTC, Taylor Hillegeist wrote: So I have this code and I have to add the element .each!(a => a.each!("a")); to the end in order for it to evaluate the range completely and act like I expect it too. Is there a better thing to put in the place of .each!(a

Re: How to force evaluation of range?

2016-02-12 Thread Xinok via Digitalmars-d-learn
On Saturday, 13 February 2016 at 01:11:53 UTC, Nicholas Wilson wrote: ... If you just want the range evaluated use walkLength It might work in this case, but in general this won't work for any range which defines .length as a member. In that case, walkLength will simply return .length of

Re: How to force evaluation of range?

2016-02-12 Thread Xinok via Digitalmars-d-learn
On Saturday, 13 February 2016 at 03:16:09 UTC, cym13 wrote: On Saturday, 13 February 2016 at 02:17:17 UTC, Xinok wrote: On Friday, 12 February 2016 at 20:43:24 UTC, Taylor Hillegeist wrote: So I have this code and I have to add the element .each!(a => a.each!("a")); to the end in order for it

Re: Challenge: fair partition function

2016-02-08 Thread Xinok via Digitalmars-d
On Monday, 8 February 2016 at 23:25:00 UTC, Andrei Alexandrescu wrote: Consider defining a function that partitions a range around a given index like this: size_t pivotPartition(alias less = (a, b) => a < b, Range) (Range r, size_t pivot); Returns x, one of the the indexes that r[pivot] would

Re: [suggestion] Automated one-stop compiler version chart

2016-02-07 Thread Xinok via Digitalmars-d
On Sunday, 7 February 2016 at 18:46:48 UTC, Nick Sabalausky wrote: I was just updating a project's .travis.yml file and noticed: It doesn't seem we have any one-stop-shop location to check all the versions of DMD/LDC/GDC currently available on travis-ci. It's be really nice if we had some

Re: Idempotent partition around median of 5?

2016-02-05 Thread Xinok via Digitalmars-d
On Friday, 5 February 2016 at 17:33:55 UTC, Era Scarecrow wrote: On Friday, 5 February 2016 at 15:41:11 UTC, Fool wrote: One swap usually decomposes into three moves. Recently from reading some interesting hacks and super code, a good swap can also be done via 3 xor operations (and avoiding

Re: Idempotent partition around median of 5?

2016-02-05 Thread Xinok via Digitalmars-d
On Friday, 5 February 2016 at 15:13:56 UTC, tn wrote: On Thursday, 4 February 2016 at 20:30:57 UTC, Timon Gehr wrote: At most 6 comparisons, <=3 swaps, idempotent (optimal number of swaps): ... Inspired by this, I made four other versions of the function that are shorter but make more

Re: Idempotent partition around median of 5?

2016-02-04 Thread Xinok via Digitalmars-d
On Thursday, 4 February 2016 at 20:30:57 UTC, Timon Gehr wrote: At most 6 comparisons, <=3 swaps, idempotent (optimal number of swaps): void partition5(ref int[5] a){ if(a[0]

Re: Idempotent partition around median of 5?

2016-02-03 Thread Xinok via Digitalmars-d
On Thursday, 4 February 2016 at 01:33:54 UTC, Era Scarecrow wrote: On Thursday, 4 February 2016 at 01:24:15 UTC, Andrei Alexandrescu wrote: This appears a simple problem: given numbers a, b, c, d, e, swap them around so as to place the median in c and partition the others around it. I.e. the

Stable Partition3 Redux

2016-02-01 Thread Xinok via Digitalmars-d
I'm not sure what the convention is for resurrecting old threads but I felt it would be best to start fresh. For reference, the older thread is here: http://forum.dlang.org/thread/pyduqwmskkkoicsxi...@forum.dlang.org tl;dr - I studied a paper with the goal of implementing a stable 3-way

Re: D vs Rust

2016-01-31 Thread Xinok via Digitalmars-d
On Sunday, 31 January 2016 at 16:30:47 UTC, Ola Fosheim Grøstad wrote: On Sunday, 31 January 2016 at 16:18:21 UTC, bearophile wrote: Regarding the code reliability, D is better than C++11 That's a bold claim. What do you mean by "code reliability"? You get as strong typing as you want with

Re: reduce -> fold?

2016-01-30 Thread Xinok via Digitalmars-d
On Saturday, 30 January 2016 at 12:11:37 UTC, Ola Fosheim Grøstad wrote: Currying is pointless, I believe Swift is removing it. ... It might be fairly useless in D but it's definitely not useless in general. It' a different design pattern and functional languages make great use of it. OTOH,

Re: Collapsing n-dimensional array to linear (1 dimensional)

2016-01-22 Thread Xinok via Digitalmars-d-learn
On Friday, 22 January 2016 at 12:07:11 UTC, abad wrote: Let's say I have an array like this: int[][][] array; And I want to generate a linear int[] based on its data. Is there a standard library method for achieving this, or must I iterate over the array manually? What I'm thinking of is

Re: Distributed Memory implementation

2016-01-18 Thread Xinok via Digitalmars-d
On Monday, 18 January 2016 at 09:56:17 UTC, Adrian Matoga wrote: ... Your idea seems interesting, but IMHO a compacting GC should be the preferred solution for heap fragmentation. Implementing a compacting GC in D would be exceedingly difficult, if not impossible, because of raw pointers,

Re: Distributed Memory implementation

2016-01-18 Thread Xinok via Digitalmars-d
On Monday, 18 January 2016 at 11:46:36 UTC, Nemanja Boric wrote: On Monday, 18 January 2016 at 09:28:59 UTC, tcak wrote: On Monday, 18 January 2016 at 08:12:03 UTC, Nemanja Boric wrote: Check https://dlang.org/phobos/std_experimental_allocator.html Which part of this module provide the

Re: topN using a heap

2016-01-18 Thread Xinok via Digitalmars-d
On Tuesday, 19 January 2016 at 00:11:40 UTC, Andrei Alexandrescu wrote: Of course not. I think this back-and-forth takes away from the gist of things. So let me summarize what has happened: 1. topN was reportedly slow. It was using a random pivot. I made it use getPivot (deterministic)

Re: Balanced match with std.regex

2015-12-14 Thread Xinok via Digitalmars-d-learn
On Tuesday, 15 December 2015 at 01:29:39 UTC, Jakob Ovrum wrote: Thanks, that makes sense. String manipulation in D without regex is pretty nice anyway, so it's not a big loss. There is a library named Pegged which can match against balanced parens:

Re: D programming video tutorial

2015-12-13 Thread Xinok via Digitalmars-d-learn
On Sunday, 13 December 2015 at 20:29:47 UTC, Pederator wrote: Hi. Does anybody who is familair with D consider to make a comprehensive D programming video tutorial / training / course? This could be encouraging and helpful for people to start with D. It could also help in promoting D

Re: functional way doing array stuff/ lambda functions

2015-12-12 Thread Xinok via Digitalmars-d-learn
On Saturday, 12 December 2015 at 23:36:43 UTC, cym13 wrote: ... So, in your example: int product(const ref int[] arr) { import std.array: array; import std.algorithm: reduce; arr = arr.reduce!((p, i) => p*i).array; } A good post overall but you got reduce wrong. In D, reduce

Re: Microsoft to contribute to Clang and LLVM project

2015-12-09 Thread Xinok via Digitalmars-d
On Monday, 7 December 2015 at 11:26:27 UTC, Bruno Medeiros wrote: With these developments, one asks again, is it wise to spend any more time working and using the Digital Mars backend for D?... I asked this very question about a year ago. The thread is here:

Re: Complexity nomenclature

2015-12-03 Thread Xinok via Digitalmars-d
On Friday, 4 December 2015 at 01:55:15 UTC, Timon Gehr wrote: Regarding nomenclature, it would be awesome if we could call this "running time" instead of "complexity". Algorithms have running times and memory usages. Problems have (time and space) complexities. I know that calling running time

Re: Will std.allocator make it easy to bypass the GC?

2015-11-14 Thread Xinok via Digitalmars-d
On Saturday, 14 November 2015 at 14:56:57 UTC, maik klein wrote: http://dlang.org/phobos/std_experimental_allocator.html I am not sure what the plan is but it seems to me that the standard library could make use of the "theAllocator" for allocation and also allow you to swap in different

std.stdio.writeln should not accept infinite ranges?

2015-11-12 Thread Xinok via Digitalmars-d
The following code compiles and runs: import std.stdio, std.random; void main() { writeln(rndGen); } Since rndGen is an infinite range, this code runs forever. It seems to be that we need to add a check for isInfinite on writeln and other related functions. Does anybody have a use case

Re: std.stdio.writeln should not accept infinite ranges?

2015-11-12 Thread Xinok via Digitalmars-d
On Friday, 13 November 2015 at 01:19:22 UTC, Andrei Alexandrescu wrote: On 11/12/2015 08:18 PM, Xinok wrote: The following code compiles and runs: import std.stdio, std.random; void main() { writeln(rndGen); } Since rndGen is an infinite range, this code runs forever. It seems to be

Re: Purity of std.conv.to!string

2015-09-26 Thread Xinok via Digitalmars-d-learn
On Saturday, 26 September 2015 at 17:08:00 UTC, Nordlöw wrote: Why is the following code not pure: float x = 3.14; import std.conv : to; auto y = x.to!string; ??? Is there a reason for it not being pure? If not, this is a serious problem as this is such a fundamental function.

Re: Floating point in the type system

2015-09-12 Thread Xinok via Digitalmars-d
On Saturday, 12 September 2015 at 16:08:31 UTC, Robert wrote: On Saturday, 12 September 2015 at 15:49:23 UTC, Atila Neves wrote: What do think is unusual? Atila It's unusual, because `float.nan != float.nan`, so one might expect that `typeof(Foo!(float.nan) != Foo!(float.nan))`, whereas

Re: Error reporting is terrible

2015-09-03 Thread Xinok via Digitalmars-d
On Thursday, 3 September 2015 at 23:56:53 UTC, Prudence wrote: After being away from D and deciding to test the idea of writing a commercial app in it, There were 2 big things that have jumped out at me: 1. The setup is a much compared to most modern day compilers and software. While VS is

Re: A Small Enhancement Idea

2015-09-02 Thread Xinok via Digitalmars-d
On Wednesday, 2 September 2015 at 19:34:53 UTC, Jack Stouffer wrote: On Wednesday, 2 September 2015 at 19:15:08 UTC, jmh530 wrote: I wasn't familiar with version(release). Would you need to compile with -version=release then? No, it seems to work with just the -release flag. The Python

Re: Dazz new description for D

2015-09-01 Thread Xinok via Digitalmars-d
On Monday, 31 August 2015 at 07:38:18 UTC, Enamex wrote: Some posters on reddit remarked that D's sales pitch on the website is unnecessarily long and unindicative... I used to suffer from long compile times, poor move semantics, and undefined behavior. Then my doctor told me about D...

Re: How many bytes in a real ?

2015-08-24 Thread Xinok via Digitalmars-d
On Monday, 24 August 2015 at 21:55:40 UTC, Guillaume Chatelet wrote: On linux x86_64 : real.sizeof == 16 but it looks like only the first the first 10 bytes are used (ie. 80bits) Is there a way to know the real size of a real ? The best I can think of is to use the mant_dig property which

Re: foreach multiple loop sugar

2015-08-18 Thread Xinok via Digitalmars-d-learn
On Tuesday, 18 August 2015 at 15:51:55 UTC, ixid wrote: Though sugar seems to be somewhat looked down upon I thought I'd suggest this- having seen the cartesianProduct function from std.algorithm in another thread I thought it would be an excellent piece of sugar in the language. It's not an

Re: Bug in std.container: SList

2015-08-14 Thread Xinok via Digitalmars-d
On Friday, 14 August 2015 at 18:12:42 UTC, anonymous wrote: Other insert* functions call the private function SList.initialize() which does the null-check for _root. I am working on a PR adding the missing call in insertAfter - that's a 1 line change. I am not a phobos dev. I would do the

Re: Bug in std.container: SList

2015-08-14 Thread Xinok via Digitalmars-d
On Friday, 14 August 2015 at 06:44:53 UTC, ted wrote: Hi, (earlier posting on D.learn, but better test included here)... dmd.2.067, dmd.2068 (64bit linux) import std.container: SList; void main() { SList!int tmp=( 4 ); SList!int tmp1; // Ensure tmp is empty

Re: Does D have syntax for adding subscopes to classes?

2015-08-12 Thread Xinok via Digitalmars-d-learn
On Wednesday, 12 August 2015 at 15:47:37 UTC, Adam D. Ruppe wrote: Example with them: ... That's the idea I had except I would use a struct instead because using a class requires a second allocation.

Re: Interpreting the D grammar

2015-08-02 Thread Xinok via Digitalmars-d
On Sunday, 2 August 2015 at 14:50:35 UTC, Jacob Carlborg wrote: I'm trying to read the D grammar [1] to enhance the D TextMate bundle. If we take the add expression as an example. It's defined like this in the grammar: AddExpression: MulExpression AddExpression + MulExpression

Re: Interpreting the D grammar

2015-08-02 Thread Xinok via Digitalmars-d
On Sunday, 2 August 2015 at 17:33:35 UTC, Jacob Carlborg wrote: On 02/08/15 18:37, MakersF wrote: Of course it's recursive! Do you want the grammar to be able to only define a finite number of programs? I don't know how this work, that's why I'm asking. But I read something about left

Is Key Type?

2015-08-02 Thread Xinok via Digitalmars-d-learn
is there a trait in D or Phobos which will tell you if a type can be used as a key for an associative array? For example, where T is some type: static assert(isKeyType!T) int[T] hashTable = ...

Re: Stable partition3 implementation

2015-07-22 Thread Xinok via Digitalmars-d
On Saturday, 11 July 2015 at 02:56:55 UTC, Timon Gehr wrote: ... The algorithm runs in O(n*log*(n)). It's not n log(n). ... I understand now. I had never heard of an iterated logarithm before. I took the asterisk to mean some constant, like a wild card if you will. Sorry for the confusion.

Re: What about GDC and LDC after DMD becomes D?

2015-07-22 Thread Xinok via Digitalmars-d
On Wednesday, 22 July 2015 at 11:42:24 UTC, Shriramana Sharma wrote: Once the front end of DMD becomes fully D, I read that the backend will also become D, but then what will happen to GDC and LDC whose backends are C++ IIUC? The Rust compiler is written in Rust but uses LLVM as a backend,

Re: Stable partition3 implementation

2015-07-10 Thread Xinok via Digitalmars-d
On Friday, 10 July 2015 at 21:26:50 UTC, Timon Gehr wrote: I think this method is likely to be less practically relevant than the one they improve upon. (log* n really is constant for all practical purposes, it is the number of times one needs to iteratively take the logarithm until a number

Re: Stable partition3 implementation

2015-07-10 Thread Xinok via Digitalmars-d
On Saturday, 11 July 2015 at 00:00:47 UTC, Andrei Alexandrescu wrote: On 7/9/15 5:57 PM, Xinok wrote: ... Any thoughts? I'd say both would be nice (not to mention the one in the paper) so how about both are present selectable with a policy ala Yes.tightMemory or something. -- Andrei I'm

Re: Stable partition3 implementation

2015-07-09 Thread Xinok via Digitalmars-d
On Thursday, 9 July 2015 at 21:57:39 UTC, Xinok wrote: I found this paper which describes an in-place algorithm with O(n) time complexity but it's over my head at the moment. http://link.springer.com/article/10.1007%2FBF01994842 I apologize, I didn't realize this link was behind a paywall.

Stable partition3 implementation

2015-07-09 Thread Xinok via Digitalmars-d
I wanted to get some feedback on a stable partition3 implementation for Phobos before I work on a pull request. I wrote this implementation which is in-place (zero memory allocations) but runs in O(n lg n) time. http://dpaste.dzfl.pl/e12f50ad947d I found this paper which describes an

Re: Map Purity

2015-06-30 Thread Xinok via Digitalmars-d-learn
On Sunday, 28 June 2015 at 15:55:51 UTC, jmh530 wrote: My understanding of pure is that a function labeled pure can only include pure functions. I've been confused by the fact that a function calling map (like below) can be labeled pure without any problems. The only way I can rationalize it

Re: A Vision on Improved DMD Template Instantiation Diagonostics

2015-06-12 Thread Xinok via Digitalmars-d
On Friday, 12 June 2015 at 15:51:02 UTC, Per Nordlöw wrote: On Friday, 12 June 2015 at 15:35:55 UTC, Xinok wrote: However, template constraints in D are much more powerful and flexible than C++ concepts. As such, there are bound to be several cases in which the compiler can't provide any

Re: A Vision on Improved DMD Template Instantiation Diagonostics

2015-06-12 Thread Xinok via Digitalmars-d
On Friday, 12 June 2015 at 12:20:58 UTC, Per Nordlöw wrote: ... Destroy. Improving compiler diagnostics for failed template instantiations would be a great start. However, template constraints in D are much more powerful and flexible than C++ concepts. As such, there are bound to be

Re: Associative array on the heap

2015-05-18 Thread Xinok via Digitalmars-d-learn
On Tuesday, 19 May 2015 at 00:31:50 UTC, Freddy wrote: Sorry mis-phrased my question, Who do you allocate a pointer to an associative array(int[string]*). Ignoring the why for a moment, one trick is to place it in an array literal so it's heap allocated. This requires writing an

Inferring Purity Woes

2015-05-15 Thread Xinok via Digitalmars-d
I've been avoiding purity in D for a while but I decided to take a stab at it today. I encountered two issues which make inferring purity difficult. (1) While the compiler infers purity for instantiated functions, it's unable to infer purity for functions within templates. Consider the

Re: Coding for solid state drives

2015-04-25 Thread Xinok via Digitalmars-d
On Saturday, 25 April 2015 at 20:12:55 UTC, Walter Bright wrote: Hard disks are dead today for anyone who cares about performance. I still use them, but only for secondary storage. For anybody who wants to buy 4TB of storage for $100, hard drives are still very much alive. Not to mention

Re: const as default for variables

2015-03-14 Thread Xinok via Digitalmars-d
On Saturday, 14 March 2015 at 20:15:30 UTC, Walter Bright wrote: I've often thought, as do many others here, that immutability should be the default for variables. [This is a long term issue. Just thought maybe it's time for a conversation about it.] Because immutable is transitive,

Purity not enforced for default arguments?

2015-03-10 Thread Xinok via Digitalmars-d-learn
The following code fails to compile because unpredictableSeed is impure: void main() { foreach(i; 0..10) writeln(pureRandom); } pure uint pureRandom() { auto r = Random(unpredictableSeed); return r.front; } However, make unpredictableSeed a

Re: Purity not enforced for default arguments?

2015-03-10 Thread Xinok via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 22:00:29 UTC, safety0ff wrote: On Tuesday, 10 March 2015 at 21:56:39 UTC, Xinok wrote: I'm inclined to believe this is a bug. https://issues.dlang.org/show_bug.cgi?id=11048 Thanks for the link, and I didn't mean to post this in D.learn. .

Re: Parallel Merge Sort

2015-03-03 Thread Xinok via Digitalmars-d
On Tuesday, 3 March 2015 at 22:55:05 UTC, Josh wrote: How can I make my parallel code more efficient. Currently, I am getting destroyed by the serial merge sort. http://pastebin.com/M0GKfTTX Thank you. I've implemented a concurrent merge sort if you want to take a look at my code. It's

Re: @inverse

2015-02-25 Thread Xinok via Digitalmars-d
On Thursday, 26 February 2015 at 01:40:32 UTC, Andrei Alexandrescu wrote: Since you're here, do you plan to fix stable sort as recently discussed? -- Andrei While the fix seems straightforward, I haven't taken the time to study the problem. I plan to do so and if I feel confident that I can

Re: @inverse

2015-02-25 Thread Xinok via Digitalmars-d
On Thursday, 26 February 2015 at 02:05:25 UTC, Sativa wrote: On Thursday, 26 February 2015 at 00:56:02 UTC, Xinok wrote: I like the idea but feel that it's application is too narrow. I prefer features which are more general and offer greater flexibility. I believe I've read somewhere that some

Re: @inverse

2015-02-25 Thread Xinok via Digitalmars-d
On Wednesday, 25 February 2015 at 21:25:49 UTC, Daniel N wrote: Just throwing an idea out there... How about using annotations to teach the compiler which functions are inverses of each-other, in order to facilitate optimizing away certain redundant operations even if they are located inside a

Re: Consistency

2015-02-15 Thread Xinok via Digitalmars-d
On Sunday, 15 February 2015 at 17:18:08 UTC, Steve D wrote: Python (built-in) dict1 = {a:1,b:2} tup1 = (0,1,2,3) arr1 = [0,1,2,3] # list type str1 = abcd print b in dict1# True print 3 in tup1 # True print 3 in arr1 # True print c in str1 # True print tup1.index(2) #

Re: Consistency

2015-02-15 Thread Xinok via Digitalmars-d
On Sunday, 15 February 2015 at 18:15:13 UTC, Meta wrote: On Sunday, 15 February 2015 at 17:18:08 UTC, Steve D wrote: Python (built-in) dict1 = {a:1,b:2} tup1 = (0,1,2,3) arr1 = [0,1,2,3] # list type str1 = abcd print b in dict1# True O(1) lookup A small nitpick, but I'm sure that

Re: Template constraints

2015-02-14 Thread Xinok via Digitalmars-d
On Saturday, 14 February 2015 at 17:00:33 UTC, Andrei Alexandrescu wrote: There's been recurring discussion about failing constraints not generating nice error messages. void fun(T)(T x) if (complicated_condition) { ... } struct Type(T)(T x) if (complicated_condition) { ... } If

Re: Suggestion: array slice through arr[base, size]

2015-02-08 Thread Xinok via Digitalmars-d
On Sunday, 8 February 2015 at 15:20:17 UTC, karl wrote: Hi, it's a bit unwieldy to write/read this: result = src[base .. base+size]; instead of: result = src[base, size]; Maybe such syntax would be a welcome addition to D? I don't see it conflicting with the existing grammar, and only the 2

Re: sortUniq

2015-01-22 Thread Xinok via Digitalmars-d
On Thursday, 22 January 2015 at 21:40:57 UTC, Andrei Alexandrescu wrote: There's this classic patter on Unix: |sort|uniq, i.e. sort some data and only display the unique elements. What would be a better integrated version - one that does sorting and uniq in one shot? I suspect the combination

Re: dlang.org redesign n+1

2015-01-21 Thread Xinok via Digitalmars-d
On Wednesday, 21 January 2015 at 14:46:22 UTC, Sebastiaan Koppe wrote: Just for fun and proof-of-concept I went ahead and forked the dlang.org site. I basically took the `do-what-everybody-else-is-doing` approach: http://dlang.skoppe.eu This gets a big thumbs up from me. The layout is

Re: auto return for some recursive functions in C++11

2015-01-14 Thread Xinok via Digitalmars-d
On Wednesday, 14 January 2015 at 22:37:22 UTC, ketmar via Digitalmars-d wrote: On Wed, 14 Jan 2015 22:29:08 + bearophile via Digitalmars-d digitalmars-d@puremagic.com wrote: According to Wikipedia: http://en.wikipedia.org/wiki/C%2B%2B14#Function_return_type_deduction C++14 is able to

Re: CTFE pow()

2015-01-01 Thread Xinok via Digitalmars-d
On Thursday, 1 January 2015 at 16:56:24 UTC, Manu via Digitalmars-d wrote: Does anyone know how to fix this? Can we please do so? It's been a problem for like 5 years it seems. It's a bit insane that we can't resolve any non-linear functions at compile time. I was looking for a relevant

  1   2   >