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
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
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
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
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, selftype.init
) ) ) ){
auto len2() {return len *
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 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: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
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
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
On 08/06/2015 11:26 PM, VlasovRoman wrote:
I have some code:
Reduced:
import std.stdio;
auto foo(T)(T)
{
return 42;
}
struct Vector(T)
{
pragma(msg, is(typeof(foo(Vector.init;// prints true
static if(is(typeof(foo(Vector.init {
static assert(false);
On Fri, 07 Aug 2015 08:42:45 +
yawniek dl...@srtnwz.com 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
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,
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
On Fri, 07 Aug 2015 08:13:01 +
yawniek dl...@srtnwz.com 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 dl...@srtnwz.com 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 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 better
On Fri, 07 Aug 2015 07:19:43 +
yawniek via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
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?
On Fri, 07 Aug 2015 07:36:39 +
yawniek dl...@srtnwz.com 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
On Fri, 07 Aug 2015 07:19:43 +
yawniek dl...@srtnwz.com 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
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
On Fri, 07 Aug 2015 08:01:27 +
yawniek dl...@srtnwz.com 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
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 Fri, 7 Aug 2015 09:43:25 +0200
Daniel Kozák ko...@dlang.cz wrote:
On Fri, 07 Aug 2015 07:36:39 +
yawniek dl...@srtnwz.com 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,
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
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
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 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
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 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 =
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
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
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
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
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.
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
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 ;
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
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 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
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];
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
{
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
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,
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
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 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
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 Fri, 07 Aug 2015 12:29:26 +
yawniek dl...@srtnwz.com 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
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.
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);
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:
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
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;
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 if
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 {
string a,b,c;
}
I
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 to
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 =
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
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; });
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
66 matches
Mail list logo