On Saturday, 8 August 2015 at 01:24:04 UTC, 岩倉 澪 wrote:
On Saturday, 8 August 2015 at 00:39:57 UTC, 岩倉 澪 wrote:
receiveTimeout(0.msecs,
(immutable Bar[] bar){ baz = cast(Bar[])bar;
});
Whoops, that should be:
receiveTimeout(0.msecs,
(immutable
On Saturday, 8 August 2015 at 00:39:57 UTC, 岩倉 澪 wrote:
Found the answer to this :)
http://forum.dlang.org/post/mailman.1706.1340318206.24740.digitalmars-d-le...@puremagic.com
I send the results from my worker thread with assumeUnique, and
then simply cast away immutable in the receiving threa
On Saturday, 8 August 2015 at 00:39:57 UTC, 岩倉 澪 wrote:
receiveTimeout(0.msecs,
(immutable Bar[] bar){ baz = cast(Bar[])bar; });
Whoops, that should be:
receiveTimeout(0.msecs,
(immutable(Bar)[] bar){ baz = cast(Bar[])bar; });
Unfortunately, this is not a very good example for
std.parallelism, since the measured times are better using the
std.algorithm.map calls. I know from past experience that
std.parallelism routines can work well when the work is spread
out correctly, so this example could be improved.
This is
and, finally, this works using the taskPool.map, as in the
std.parallelism example. So, the trick appears to be that the
call to chomp is needed.
auto lineRange = File(fn).byLineCopy();
auto chomped = std.algorithm.map!"a.chomp"(lineRange);
auto nums = taskPool.map!(to!
On Friday, 7 August 2015 at 22:13:35 UTC, 岩倉 澪 wrote:
"message" is local to the delegate that receiveTimeout takes.
I want to use "message" outside of the delegate in the
receiving thread. However, if you send an immutable value from
the worker thread, afaict there would be no way to assign it
On 08/07/2015 06:59 AM, drug wrote:
What is the best way to create range from uniform() function (in other
words create a generator based on some function, returning, say, scalar,
not range)? I did http://dpaste.dzfl.pl/53e3d9255cd7 but I'm not sure
it's the best way. At least sequence using look
I tried to create a working example from the std.parallelism
taskPool.map code, and it throws with empty strings with length 1
being passed to to!double. Anyone have a working example? I'm
building on Windows with 2.067.1 dmd.
import std.parallelism;
import std.algorithm;
import std.stdio;
i
On Friday, 7 August 2015 at 14:45:44 UTC, Nordlöw wrote:
On Friday, 7 August 2015 at 14:30:55 UTC, Nordlöw wrote:
Any suggestions on adding support for `binaryFun!pred` aswell?
I cracked it.
template isSortedRange(T, alias pred = "a < b")
{
import std.traits : TemplateArgsOf;
static
On Friday, 7 August 2015 at 18:51:45 UTC, Steven Schveighoffer
wrote:
On 8/7/15 2:37 PM, Steven Schveighoffer wrote:
I'll file a bug on this.
https://issues.dlang.org/show_bug.cgi?id=14886
-Steve
Thanks. The workaround works ok.
On 08/07/2015 03:24 PM, Marek Janukowicz wrote:> This program works fine:
>
> import std.concurrency;
>
> struct A {
>string a,b;
> }
>
> void main () {
>immutable A a = immutable A( "blah" );
>send( thisTid, a );
> }
>
> But if change struct A declaration to:
>
> struct A {
>strin
This also works.
auto sm = File(fn).byLineCopy()
.map!"a.chomp"()
.map!(to!double)
.map!"a.log10"()
.sum();
writeln("sum=",sm);
This program works fine:
import std.concurrency;
struct A {
string a,b;
}
void main () {
immutable A a = immutable A( "blah" );
send( thisTid, a );
}
But if change struct A declaration to:
struct A {
string a,b,c;
}
I get this error during compilation:
/opt/dmd2/linux/bin64/../../src
This appears to work ... at least, no exception:
auto sm = File(fn).byLine(KeepTerminator.no)
.map!"a.chomp"()
.map!"a.idup"()
.map!(to!double)
.map!"a.log10"()
.sum();
writeln("sum=",sm);
On 08/07/2015 05:37 AM, Reflexive wrote:
> Is it you who wrote "Programming in D" ?
Yes. (The other Ali Çehreli is a musician. :) )
> It's a great e-book, very clear, I love it.
Thank you very much for the kind words. Which format are you using? It
is good to hear that it is acceptable as an
On Friday, 7 August 2015 at 15:55:33 UTC, Chris wrote:
To stop threads immediately, I've found that the best way is to
use a shared variable, typically a bool, that is changed only
in one place.
...
Unfortunately, sending an abort message to a thread as in
`send(thread, true)` takes too long.
On 8/7/15 2:37 PM, Steven Schveighoffer wrote:
I'll file a bug on this.
https://issues.dlang.org/show_bug.cgi?id=14886
-Steve
On 8/7/15 2:19 PM, Jay Norwood wrote:
This appears to hang up dmd compiler 2.067.1. Changing parallel(s) to s
works ok. Is this a known problem?
import std.stdio;
import std.string;
import std.format;
import std.range;
import std.parallelism;
int main(string[] argv)
{
string s[10];
This appears to hang up dmd compiler 2.067.1. Changing
parallel(s) to s works ok. Is this a known problem?
import std.stdio;
import std.string;
import std.format;
import std.range;
import std.parallelism;
int main(string[] argv)
{
string s[10];
foreach (i, ref si ; parallel
On 8/7/15 1:19 PM, Marek Janukowicz wrote:
How do I mark a function as returning shared object?
This won't compile:
shared Foo foo () {
...
}
This does, but looks somewhat awkward to me:
shared (shared Foo) foo () {
...
}
shared, const, immutable when applied to a member function act
On Friday, 7 August 2015 at 17:19:16 UTC, Marek Janukowicz wrote:
shared (shared Foo) foo () {
...
}
That's correct, though the recommendation now is to put the other
shared on teh right and change the parens a little:
shared(Foo) foo() shared {
}
The ones without parens refer to the `th
How do I mark a function as returning shared object?
This won't compile:
shared Foo foo () {
...
}
This does, but looks somewhat awkward to me:
shared (shared Foo) foo () {
...
}
--
Marek Janukowicz
On Thursday, 6 August 2015 at 17:01:32 UTC, chris wrote:
since memorystream is deprecated how do i do something like
this with Input and Output ranges? How can i fill up an array
with ranges like you can do with streams?
Thanks.
The InputRange primitives already exist for arrays, they are
lo
On Friday, 7 August 2015 at 15:55:33 UTC, Chris wrote:
Using a shared boolean is probably not the "best way", I should
have said the most efficient and reliable way.
On Thursday, 6 August 2015 at 21:17:15 UTC, 岩倉 澪 wrote:
On Tuesday, 4 August 2015 at 08:35:10 UTC, Dicebot wrote:
// in real app use `receiveTimeout` to do useful stuff
until
// result message is received
auto output = receiveOnly!(immutable(Bar)[]);
New question: how would I rece
On Friday, 7 August 2015 at 14:30:55 UTC, Nordlöw wrote:
Any suggestions on adding support for `binaryFun!pred` aswell?
I cracked it.
template isSortedRange(T, alias pred = "a < b")
{
import std.traits : TemplateArgsOf;
static if (TemplateArgsOf!T.length == 2)
{
import std
On Friday, 7 August 2015 at 14:13:24 UTC, Nordlöw wrote:
How do check that the second template argument to the instance
of SortedRange matches `pred`?
Using TemplateArgsOf.
I found a solution:
template isSortedRange(T, alias pred = "a < b")
{
import std.traits : TemplateArgsOf;
enum i
On Friday, 7 August 2015 at 11:45:22 UTC, Nordlöw wrote:
Can somebody please explain and help out with variadic version
of `isInstanceOf`?
Here's a try at isSortedRange:
enum bool isSortedRange(T, alias pred = "a < b") = is(T ==
SortedRange!(Args[0], pred), Args...);
unittest
{
alias R
What is the best way to create range from uniform() function (in other
words create a generator based on some function, returning, say, scalar,
not range)? I did http://dpaste.dzfl.pl/53e3d9255cd7 but I'm not sure
it's the best way. At least sequence using looks ugly
Okay, so, I decided to scrap the BinaryHeap version of the
priority queue, going back to basics and utilizing a simple
array. It works, huzzah!
Code:
module data_structures.priority_queue;
import std.array;
import std.range: assumeSorted;
import std.typecons: Tuple;
/*
Templated Prio
On Friday, 7 August 2015 at 11:45:22 UTC, Nordlöw wrote:
Can somebody please explain and help out with variadic version
of `isInstanceOf`?
Here's a step forward:
/**
Returns true if $(D T) is an instance of the template $(D T)
with template
parameters $(D Ps).
*/
enum bool isInstanceOf
At the moment, thanks to John Colvin's work, you can write D in
an ipython/Jupyter notebook. I find it a nicer work flow for
playing around with things, since you can see results inline, and
iterate rapidly. In theory maybe no better than having your
editor/IDE hooked up, but the difference b
On Friday, 7 August 2015 at 11:45:22 UTC, Nordlöw wrote:
To implement a new trait
isSortedRange(R, pred)
needed for SortedRange specializations I need a variant of
enum bool isInstanceOf(alias S, T) = is(T == S!Args,
Args...);
that takes the `pred` argument aswell.
But I have no cl
OK, I got it. Thank you very much.
Is it you who wrote "Programming in D" ? It's a great e-book,
very clear, I love it.
Alex
On Fri, 07 Aug 2015 12:29:26 +
"yawniek" wrote:
> On Friday, 7 August 2015 at 11:45:00 UTC, Daniel Kozak wrote:
> > On Friday, 7 August 2015 at 09:12:32 UTC, yawniek wrote:
> >> [...]
> >
> > Can you try it without write operation (comment out all write)?
> > And than try it without uncompr
On Friday, 7 August 2015 at 11:45:00 UTC, Daniel Kozak wrote:
On Friday, 7 August 2015 at 09:12:32 UTC, yawniek wrote:
[...]
Can you try it without write operation (comment out all write)?
And than try it without uncompression?
// without compression:
void main(string[] args)
{
auto f =
To implement a new trait
isSortedRange(R, pred)
needed for SortedRange specializations I need a variant of
enum bool isInstanceOf(alias S, T) = is(T == S!Args, Args...);
that takes the `pred` argument aswell.
But I have no clue what to do with
enum bool isInstanceOf(alias S, T, T
On Friday, 7 August 2015 at 11:45:22 UTC, Nordlöw wrote:
enum bool isInstanceOf(alias S, T, TParams)
Correction:
enum bool isInstanceOf(alias S, T, TParams...)
On Friday, 7 August 2015 at 11:40:54 UTC, Laeeth Isharc wrote:
What's the best way to check if an (optional) argument has been
passed? One way is to use a default value, but I wonder if
there is a tidier approach
Thanks.
(For startDate and endDate below)
struct NanoClientOptions
{
s
What's the best way to check if an (optional) argument has been
passed? One way is to use a default value, but I wonder if there
is a tidier approach
Thanks.
(For startDate and endDate below)
struct NanoClientOptions
{
string nanoUrl="tcp://127.0.0.1:";
string[] tickers;
On Friday, 7 August 2015 at 09:12:32 UTC, yawniek wrote:
On Friday, 7 August 2015 at 08:50:11 UTC, Daniel Kozák wrote:
> ldc[2] -O -release -boundscheck=off -singleobj app.d
ldc 0.15.2 beta2
2.86s user 0.55s system 77% cpu 4.392 total
v2.068-devel-8f81ffc
2.86s user 0.67s system 78% cpu 4.47
On Friday, 7 August 2015 at 10:01:39 UTC, Timon Gehr wrote:
On 08/07/2015 11:03 AM, Tofu Ninja wrote:
On Friday, 7 August 2015 at 08:18:04 UTC, Nordlöw wrote:
On Friday, 7 August 2015 at 05:21:32 UTC, Tofu Ninja wrote:
HAHAH wow, this is hilarious, I just checked, nothing in
std.algo
takes adv
On 08/07/2015 11:03 AM, Tofu Ninja wrote:
On Friday, 7 August 2015 at 08:18:04 UTC, Nordlöw wrote:
On Friday, 7 August 2015 at 05:21:32 UTC, Tofu Ninja wrote:
HAHAH wow, this is hilarious, I just checked, nothing in std.algo
takes advantage of sorted ranges, sort doesn't even take advantage of
On 08/07/2015 02:05 AM, Reflexive wrote:
> class sabot{
> carte[] sabotarray ;
>
> this(){
> int i ;
> for (i=1 ; i<=52 ; i++){
> carte tempcarte ;
> tempcarte.id = i ;
> sabotarray[] ~= tempcarte ; // line 17
dmd 2.068 gives a
On Friday, 7 August 2015 at 08:50:11 UTC, Daniel Kozák wrote:
> ldc[2] -O -release -boundscheck=off -singleobj app.d
ldc 0.15.2 beta2
2.86s user 0.55s system 77% cpu 4.392 total
v2.068-devel-8f81ffc
2.86s user 0.67s system 78% cpu 4.476 total
v2.067
2.88s user 0.67s system 78% cpu 4.529 tota
Hello
I just began to learn D. I have some experience with Visual Basic
and (very little) C/C++. Last years I have been working with PHP.
So, I try to make up a class representation of a 52 cards deck.
This way :
// sabot.d
// version 0.0.1
import std.stdio ;
void main(){
auto deck
On Friday, 7 August 2015 at 08:18:04 UTC, Nordlöw wrote:
On Friday, 7 August 2015 at 05:21:32 UTC, Tofu Ninja wrote:
HAHAH wow, this is hilarious, I just checked, nothing in
std.algo takes advantage of sorted ranges, sort doesn't even
take advantage of it! You pass a sorted range into sort and
On 08/06/2015 11:26 PM, VlasovRoman wrote:
I have some code:
Filed:
https://issues.dlang.org/show_bug.cgi?id=14883
Ali
On Friday, 7 August 2015 at 08:18:04 UTC, Nordlöw wrote:
On Friday, 7 August 2015 at 05:21:32 UTC, Tofu Ninja wrote:
HAHAH wow, this is hilarious, I just checked, nothing in
std.algo takes advantage of sorted ranges, sort doesn't even
take advantage of it! You pass a sorted range into sort and
On Fri, 07 Aug 2015 08:42:45 +
"yawniek" wrote:
> On Friday, 7 August 2015 at 08:24:11 UTC, Daniel Kozák wrote:
>
> > can you try it with ldc?
> >
> > ldc[2] -O -release -boundscheck=off -singleobj app.d
>
>
> ldc 0.15.2 beta2
> 2.86s user 0.55s system 77% cpu 4.392 total
>
> v2.068-dev
On Friday, 7 August 2015 at 08:24:11 UTC, Daniel Kozák wrote:
can you try it with ldc?
ldc[2] -O -release -boundscheck=off -singleobj app.d
ldc 0.15.2 beta2
2.86s user 0.55s system 77% cpu 4.392 total
v2.068-devel-8f81ffc
2.86s user 0.67s system 78% cpu 4.476 total
v2.067
2.88s user 0.67s
On Fri, 07 Aug 2015 08:13:01 +
"yawniek" wrote:
> On Friday, 7 August 2015 at 08:05:01 UTC, Daniel Kozák wrote:
> > import
> > std.zlib,
> > std.file,
> > std.stdio,
> > std.conv;
> >
> > void main(string[] args)
> > {
> > auto f = File(args[1], "rb");
> > auto uncompressor = new
On Fri, 07 Aug 2015 08:13:01 +
"yawniek" wrote:
> On Friday, 7 August 2015 at 08:05:01 UTC, Daniel Kozák wrote:
> > import
> > std.zlib,
> > std.file,
> > std.stdio,
> > std.conv;
> >
> > void main(string[] args)
> > {
> > auto f = File(args[1], "rb");
> > auto uncompressor = new
On Friday, 7 August 2015 at 05:21:32 UTC, Tofu Ninja wrote:
HAHAH wow, this is hilarious, I just checked, nothing in
std.algo takes advantage of sorted ranges, sort doesn't even
take advantage of it! You pass a sorted range into sort and it
will just resort it! Wow
Who fixes this?
I can
On Friday, 7 August 2015 at 08:05:01 UTC, Daniel Kozák wrote:
import
std.zlib,
std.file,
std.stdio,
std.conv;
void main(string[] args)
{
auto f = File(args[1], "rb");
auto uncompressor = new UnCompress(HeaderFormat.gzip);
foreach (buffer; f.byChunk(4096))
{
auto uncomp
On Fri, 7 Aug 2015 09:43:25 +0200
Daniel Kozák wrote:
>
> On Fri, 07 Aug 2015 07:36:39 +
> "yawniek" wrote:
>
> > On Friday, 7 August 2015 at 07:29:15 UTC, Daniel Kozák wrote:
> > > Which compiler and version. There has been some performance
> > > problem with IO on OSX, it should be fix
On Fri, 07 Aug 2015 08:01:27 +
"yawniek" wrote:
> On Friday, 7 August 2015 at 07:48:25 UTC, yawniek wrote:
> > On Friday, 7 August 2015 at 07:43:25 UTC, Daniel Kozák wrote:
> > the fastest version i could come up so far is below.
> > std.conv slows it down.
> > going from a 4kb to a 4mb buff
On Friday, 7 August 2015 at 07:48:25 UTC, yawniek wrote:
On Friday, 7 August 2015 at 07:43:25 UTC, Daniel Kozák wrote:
the fastest version i could come up so far is below.
std.conv slows it down.
going from a 4kb to a 4mb buffer helped. now i'm within 30% of
gzcat's performance.
ok maybe not,
On Friday, 7 August 2015 at 07:43:25 UTC, Daniel Kozák wrote:
i don't understand why the program crashes when i do not do
the .dup
This is weird. I would say it should not crash
exactely. but try it yourself.
the fastest version i could come up so far is below.
std.conv slows it down.
going f
On Fri, 07 Aug 2015 07:19:43 +
"yawniek" wrote:
> hi,
>
> unpacking files is kinda slow, probably i'm doing something wrong.
>
> below code is about half the speed of gnu zcat on my os x machine.
> why?
>
> why do i need to .dup the buffer?
It depends. In your case you don't need to.
by
On Fri, 07 Aug 2015 07:36:39 +
"yawniek" wrote:
> On Friday, 7 August 2015 at 07:29:15 UTC, Daniel Kozák wrote:
> > Which compiler and version. There has been some performance
> > problem with IO on OSX, it should be fixed in 2.068 release
>
> i'm on master. v2.068-devel-8f81ffc
> also cha
On Friday, 7 August 2015 at 07:29:15 UTC, Daniel Kozák wrote:
Which compiler and version. There has been some performance
problem with IO on OSX, it should be fixed in 2.068 release
i'm on master. v2.068-devel-8f81ffc
also changed file read mode to "rb".
i don't understand why the program cras
On Fri, 07 Aug 2015 07:19:43 +
yawniek via Digitalmars-d-learn
wrote:
> hi,
>
> unpacking files is kinda slow, probably i'm doing something wrong.
>
> below code is about half the speed of gnu zcat on my os x machine.
> why?
>
> why do i need to .dup the buffer?
> can i get rid of the cas
hi,
unpacking files is kinda slow, probably i'm doing something wrong.
below code is about half the speed of gnu zcat on my os x machine.
why?
why do i need to .dup the buffer?
can i get rid of the casts?
the chunk size has only a marginal influence.
https://github.com/yannick/zcatd
import
On Friday, 7 August 2015 at 06:26:21 UTC, VlasovRoman wrote:
I have some code:
import std.stdio;
auto dot(T, R)(T x, R y) {
return x * y;
}
struct Vector(T)
{
alias selftype = Vector!T;
int len = 5;
pure:
const @property{
static if( is( typeof( dot( selftype.init,
self
65 matches
Mail list logo