On Thu, 26 Mar 2015 05:44:13 +, Jean pierre wrote:
> auto i = s++; // OUCH, but we expect S.i...
but why one expecting `i` here? there IS `opUnary` overload, and `++`
corretly transformed to prefix form. there is simply NO postfix form in
semantically analyzed code, *all* postfix incremen
On Thursday, 26 March 2015 at 04:57:55 UTC, ketmar wrote:
On Tue, 24 Mar 2015 16:49:01 +, Nicolas Sicard wrote:
I don't know if this is a bug or expected behaviour. The
struct is
mutable, assignable and pre-increment operator works. But
post-increment
doesn't compile because of the immuta
On Thursday, 26 March 2015 at 04:52:23 UTC, Belly wrote:
Hello, just installed D today. I have this code:
import std.stdio;
import win32.windef;
import win32.winbase;
void main()
{
LPSTR lpBuffer;
PDWORD lpnSize;
int result = GetComputerNameA(lpBuffer, lpnSize);
writeln(result)
On 26/03/2015 5:52 p.m., Belly wrote:
Hello, just installed D today. I have this code:
import std.stdio;
import win32.windef;
import win32.winbase;
void main()
{
LPSTR lpBuffer;
PDWORD lpnSize;
int result = GetComputerNameA(lpBuffer, lpnSize);
writeln(result);
}
It passes
On Tue, 24 Mar 2015 16:49:01 +, Nicolas Sicard wrote:
> I don't know if this is a bug or expected behaviour. The struct is
> mutable, assignable and pre-increment operator works. But post-increment
> doesn't compile because of the immutable member.
>
> --
> struct S {
> int i;
> imm
On Tue, 24 Mar 2015 16:49:01 +, Nicolas Sicard wrote:
> I don't know if this is a bug or expected behaviour. The struct is
> mutable, assignable and pre-increment operator works. But post-increment
> doesn't compile because of the immutable member.
>
> --
> struct S {
> int i;
> imm
Hello, just installed D today. I have this code:
import std.stdio;
import win32.windef;
import win32.winbase;
void main()
{
LPSTR lpBuffer;
PDWORD lpnSize;
int result = GetComputerNameA(lpBuffer, lpnSize);
writeln(result);
}
It passes zeroes to the API, I'm stuck and can't find
On 3/25/15 1:29 PM, Hugo wrote:
On Wednesday, 25 March 2015 at 17:09:05 UTC, John Colvin wrote:
As per the signature in the docs:
void append(T, Endian endianness = Endian.bigEndian, R)(R range, T value)
The endianness is the second template argument. What you need to write is
buffer.append!(
On 3/25/15 9:51 AM, Ali Çehreli wrote:
On 12/09/2014 08:53 AM, Steven Schveighoffer wrote:
> On 12/9/14 11:17 AM, ketmar via Digitalmars-d-learn wrote:
>> that file can be already finalized. please remember that `~this()` is
>> more a finalizer than destructor, and it's called on *dead* obje
On Thursday, 26 March 2015 at 01:04:06 UTC, Jakob Ovrum wrote:
On Thursday, 26 March 2015 at 00:41:50 UTC, Laeeth Isharc wrote:
Yeah, it is not very intuitive. But it works.
Thanks.
Next question - how can I correctly deal with inconsiderately
chosen JSON field names like 'private' (which co
On Thursday, 26 March 2015 at 00:41:50 UTC, Laeeth Isharc wrote:
Yeah, it is not very intuitive. But it works.
Thanks.
Next question - how can I correctly deal with inconsiderately
chosen JSON field names like 'private' (which conflict in a
struct declaration with D language keywords). A ha
On Thursday, 26 March 2015 at 00:41:50 UTC, Laeeth Isharc wrote:
Yeah, it is not very intuitive. But it works.
Thanks.
Next question - how can I correctly deal with inconsiderately
chosen JSON field names like 'private' (which conflict in a
struct declaration with D language keywords). A ha
Yeah, it is not very intuitive. But it works.
Thanks.
Next question - how can I correctly deal with inconsiderately
chosen JSON field names like 'private' (which conflict in a
struct declaration with D language keywords). A hack is to do a
search and replace on the JSON before presenting it
Ivan Kazmenko:
arr.map !(to !(string))
.join (" ")
.writeln;
I suggest to not put a space before the bang (!), because it's
confusing for me.
Also, "arr.map !(to !(string))" is better written "arr.map!text".
But even better is to use the range formatting of writefln,
a
Nordlöw:
Ahh, a Binary Heap perfectly matches my needs.
https://en.wikipedia.org/wiki/Binary_heap
http://dlang.org/phobos/std_container_binaryheap.html
But isn't topNCopy using a heap?
Bye,
bearophile
On Wednesday, 25 March 2015 at 17:49:49 UTC, Tobias Pankrath
wrote:
What's wrong with binary heaps?
Ahh, a Binary Heap perfectly matches my needs.
https://en.wikipedia.org/wiki/Binary_heap
http://dlang.org/phobos/std_container_binaryheap.html
Thx
On Wednesday, 25 March 2015 at 20:09:53 UTC, bearophile wrote:
This is still not very efficient (perhaps the last sorting has
to be stable):
void main() {
import std.stdio, std.algorithm, std.typecons, std.array;
[7, 5, 7, 3, 3, 5, 3, 3, 0, 3, 1, 1, 5, 1, 1, 1, 2, 2, 8,
5, 8, 8]
On Wednesday, 25 March 2015 at 20:17:57 UTC, bearophile wrote:
Ivan Kazmenko:
(1) For me, the name of the function is obscure. Something
like sortBy would be a lot easier to find than schwartzSort.
I've asked to change the name of that function for years. But
Andrei Alexandrescu is a adaman
On Wednesday, 25 March 2015 at 20:09:53 UTC, bearophile wrote:
Dennis Ritchie:
A more effective solution for C ++:
#include
#include
#include
int main() {
using namespace ranges;
auto rng = istream( std::cin )
| to_vector
| action::sort
| view::group_by( st
On Wednesday, 25 March 2015 at 20:02:20 UTC, Ivan Kazmenko wrote:
Will file an issue soon.
Here it is:
https://issues.dlang.org/show_bug.cgi?id=14340
And another one, a 2.067 regression:
https://issues.dlang.org/show_bug.cgi?id=14341
Ivan Kazmenko:
(1) For me, the name of the function is obscure. Something
like sortBy would be a lot easier to find than schwartzSort.
I've asked to change the name of that function for years. But
Andrei Alexandrescu is a adamantly against changing that pet name
he has chosen. This is irrat
Dennis Ritchie:
A more effective solution for C ++:
#include
#include
#include
int main() {
using namespace ranges;
auto rng = istream( std::cin )
| to_vector
| action::sort
| view::group_by( std::equal_to() )
| copy
| action::stab
On Wednesday, 25 March 2015 at 19:32:43 UTC, Dennis Ritchie wrote:
On Wednesday, 25 March 2015 at 19:01:43 UTC, bearophile wrote:
One solution:
Thanks.
On Wednesday, 25 March 2015 at 19:03:27 UTC, bearophile wrote:
But calling "count" for each item is not efficient (in both C#
and D). If you
On Wednesday, 25 March 2015 at 20:02:20 UTC, Ivan Kazmenko wrote:
(2) The documentation says it is more efficient than the first
version in the number of comparisons (verbose lambda with plain
sort) [1], but I don't get how it is possible: unless we know
than (not pred1(a,b)) and (not !pred1(a,
On Wednesday, 25 March 2015 at 19:01:43 UTC, bearophile wrote:
One solution:
Thanks.
On Wednesday, 25 March 2015 at 19:03:27 UTC, bearophile wrote:
But calling "count" for each item is not efficient (in both C#
and D). If your array is largish, then you need a more
efficient solution.
A mo
Ali Çehreli:
Do you know the story about groupBy?
It's a long messy story. Look for it with another name, like
chunkBy or something like that.
Bye,
bearophile
On 03/25/2015 12:01 PM, bearophile wrote:
bearophile
Do you know the story about groupBy? I see it in the documentation but
my git head does not have it:
http://dlang.org/phobos/std_algorithm_iteration.html#.groupBy
Ali
.schwartzSort!(x => tuple(-arr.count!(y => y == x), x))
But calling "count" for each item is not efficient (in both C#
and D). If your array is largish, then you need a more efficient
solution.
Bye,
bearophile
Dennis Ritchie:
int[] arr = { 7, 5, 7, 3, 3, 5, 3, 3, 0, 3, 1, 1, 5, 1,
1, 1, 2, 2, 8, 5, 8, 8 };
Console.WriteLine(string.Join(" ",
arr.OrderByDescending(x => arr.Count(y => y == x)).ThenBy(x =>
x)));
// prints 1 1 1 1 1 3 3 3 3 3 5 5 5 5 8 8 8 2 2 7 7 0
One solutio
Hi,
Can you please tell how to rewrite this code to D?
using System;
using System.Linq;
class Sort
{
static void Main()
{
int[] arr = { 7, 5, 7, 3, 3, 5, 3, 3, 0, 3, 1, 1, 5, 1,
1, 1, 2, 2, 8, 5, 8, 8 };
Console.WriteLine(string.Join(" ",
arr.OrderByDescending(x => arr.C
On Wednesday, 25 March 2015 at 17:25:50 UTC, Sad panda wrote:
Thread.sleep(200.msecs);
Thread.sleep(12.seconds);
Thread.sleep(1.minutes);
There we go, thank you so much.
On Wednesday, 25 March 2015 at 14:40:28 UTC, Per Nordlöw wrote:
On Wednesday, 25 March 2015 at 13:55:29 UTC, bearophile wrote:
Nordlöw:
I have graph traversal algorithm that needs to keep track of
the N "best" node visit.
std.algorithm.topNCopy?
Bye,
bearophile
Notice that, ideally, I wou
On Wednesday, 25 March 2015 at 17:23:40 UTC, Israel wrote:
What is the proper way of adding sleep time to a program?
The documentation examples are exactly how you can do it:
Thread.sleep( dur!("msecs")( 50 ) ); // sleep for 50 milliseconds
Thread.sleep( dur!("seconds")( 5 ) ); // sleep for 5
On 03/25/2015 10:23 AM, Israel wrote:
> Ive tried using google but no matter what code i find it either doesnt
> work, compiler gives me errors or maybe the code is deprecated.
>
> What is the proper way of adding sleep time to a program?
> Ive tried..
>
> import std.stdio;
> import core.thread;
On Wednesday, 25 March 2015 at 17:09:05 UTC, John Colvin wrote:
As per the signature in the docs:
void append(T, Endian endianness = Endian.bigEndian, R)(R
range, T value)
The endianness is the second template argument. What you need
to write is
buffer.append!(uint,
Endian.littleEndian)(c
On Wednesday, 25 March 2015 at 17:23:40 UTC, Israel wrote:
Ive tried using google but no matter what code i find it either
doesnt work, compiler gives me errors or maybe the code is
deprecated.
What is the proper way of adding sleep time to a program?
Ive tried..
import std.stdio;
import core
Ive tried using google but no matter what code i find it either
doesnt work, compiler gives me errors or maybe the code is
deprecated.
What is the proper way of adding sleep time to a program?
Ive tried..
import std.stdio;
import core.thread;
void main()
{
writeln("Sleep..");
sleep(
On Monday, 23 March 2015 at 13:29:15 UTC, wobbles wrote:
Maybe this should be distributed in the DMD installer?
i don't know :)
On Wednesday, 25 March 2015 at 15:44:50 UTC, Hugo wrote:
Hi,
I need to append an uint as an array of ubytes (in little
endian) to an existing array of ubytes. I tried to compile this
code (with dmd 2.066.1 under Windows 7 x86-64):
void main() {
ubyte[] buffer = [0x1f, 0x8b, 0x08, 0x00];
On Wednesday, 25 March 2015 at 07:12:56 UTC, thedeemon wrote:
It's for server side, but probably contains stuff you need for
client too.
Yeah, I've been meaning to write a client for a while but haven't
gotten around to it yet. What you do is make a HTTP request with
a particular header, and
Hi,
I need to append an uint as an array of ubytes (in little endian)
to an existing array of ubytes. I tried to compile this code
(with dmd 2.066.1 under Windows 7 x86-64):
void main() {
ubyte[] buffer = [0x1f, 0x8b, 0x08, 0x00];
import std.system;
import std.datetime : Clock, stdTi
On Wednesday, 25 March 2015 at 13:55:29 UTC, bearophile wrote:
Nordlöw:
I have graph traversal algorithm that needs to keep track of
the N "best" node visit.
std.algorithm.topNCopy?
Bye,
bearophile
Notice that, ideally, I would like my list of top-nodes to have a
fixed size during the who
On Wednesday, 25 March 2015 at 13:55:29 UTC, bearophile wrote:
Nordlöw:
I have graph traversal algorithm that needs to keep track of
the N "best" node visit.
std.algorithm.topNCopy?
Bye,
bearophile
Could you please elaborate a bit how you mean this should be
used. Notice that the number o
Nordlöw:
I have graph traversal algorithm that needs to keep track of
the N "best" node visit.
std.algorithm.topNCopy?
Bye,
bearophile
On 12/09/2014 08:53 AM, Steven Schveighoffer wrote:
> On 12/9/14 11:17 AM, ketmar via Digitalmars-d-learn wrote:
>> that file can be already finalized. please remember that `~this()` is
>> more a finalizer than destructor, and it's called on *dead* object.
Agreed: D has a terminology issue here
I have graph traversal algorithm that needs to keep track of the
N "best" node visit. Every time a visit a new node I get its
goodness along with a ref to it. I then want to compare it to
every currently best node in this list and replace it with the
worst one if its better than the worst. How
On Wednesday, 25 March 2015 at 08:55:14 UTC, bearophile wrote:
matovitch:
I am curious to know how isInputRange is implemented since I
wanted to do kind of the same but I am afraid it's full of
(ugly)
traits and template trickeries where haskell type classes are
quite neat and essentially a d
matovitch:
I am curious to know how isInputRange is implemented since I
wanted to do kind of the same but I am afraid it's full of
(ugly)
traits and template trickeries where haskell type classes are
quite neat and essentially a declaration of an interface.
Take a look at the sources and lea
Thanks for the precisions on template constraint and template
specialization...Indeed wath I want to do look like isInputRange
constraint. Haskell have something like :
//(Pseudo D-Haskell)
void foo(InputRange R)(R r);
//D equivalent
void foo(R)(R r) if (isInputRange(R));
Except they call the
On Tuesday, 24 March 2015 at 17:55:38 UTC, Ilya Korobitsyn wrote:
Hello!
Is there any websocket client implementation in D?
There's some WebSocket stuff here:
https://github.com/adamdruppe/arsd/blob/master/cgi.d
It's for server side, but probably contains stuff you need for
client too.
50 matches
Mail list logo