Is there a function to do this?
If not and I/someone writes it, is there interest to add it to std.datetime?
Duration t = ...;
t.to!string => 5 secs, 889 ms, and 811 μs
t.round.to!string=> 5 secs
t=...;
t.to!string => 889 ms, and 811 μs
t.round.to!string=> 889 secs
Use case: shorter logs
On Thu, Feb 13, 2014 at 5:50 PM, Steven Schveighoffer
wrote:
> On Thu, 13 Feb 2014 19:06:45 -0500, timotheecour
> wrote:
>
> On Thursday, 13 February 2014 at 23:56:35 UTC, Timothee Cour
>> wrote:
>>
>>> how to iterate over an AA by key-value pair (tuple)?
>>> use case:
>>> avoid interrupting UFC
On Fri, Feb 14, 2014 at 3:54 AM, Meta wrote:
> It seems strange that it would choke now, as Cons is a struct. Therefore,
> Cons!(Three, ...) should create a new type, and `L: Cons!(a, b), a, b`
> shouldn't be any trouble to destructure into two types, `Three` and
> `Cons!(Two, ...)`. It had no pr
On Friday, 14 February 2014 at 03:48:13 UTC, Uranuz wrote:
{ if( exc.inheritsOrIs(type) ) //Checking type of
This function is basically the same as the cast function in
druntime. Look for _d_isbaseof in the file
dmd2/src/druntime/src/rt
https://github.com/D-Programming-Language/d
Yes. I was thinking about this but I want some more "clear
looking" way of attaching handlers for errors, because I could
have a lot of them and using a lot of if operators is not good
for me.
Exception e = ...;
if(auto b = cast(BaseHTTPException) e) {
// use b of that type
} else if(auto
I suddenly posted unfinished message.
In my web application on D I want to implement some type of
"event based error handling". I'm process some events of request
handler with some wodified version of this:
http://code.dlang.org/packages/std_event
I'm trying to implement error handling in event
The easiest way is to simply use cast:
Exception e = ...;
if(auto b = cast(BaseHTTPException) e) {
// use b of that type
} else if(auto s = cast(SpecializedHTTPException) e) {
// use s, e is of this type
}
and so on.
On Friday, 14 February 2014 at 03:37:16 UTC, Uranuz wrote:
Is it possib
In my web application on D I want to implement some type of
"event based error handling". I'm process some events of request
handler with some wodified version of this:
http://code.dlang.org/packages/std_event
I'm trying to implement error handling in event "onError". I pass
Throwable object a
On Friday, 14 February 2014 at 02:41:12 UTC, bearophile wrote:
Meta:
alias list1 = Cons!(Three, Cons!(Two, Cons!(Four, Cons!(One,
Nil;
alias numlHead(L: Cons!(a, b), a, b) = a;
alias numlTail(L: Cons!(a, b), a, b) = b;
But the compiler is complaining loudly about a mismatch:
/d43/f234
On Friday, 14 February 2014 at 01:58:13 UTC, Nick Sabalausky
wrote:
On 2/13/2014 8:09 PM, Meta wrote:
I'm using Windows 7 x64, but compiling 32-bit DMD. DMD
compiles fine,
but the linker warns about a "Warning 9: Unknown Option : LA".
After
that, when trying to compile Druntime, DMD chokes with
On Friday, 14 February 2014 at 01:09:42 UTC, Meta wrote:
I'm using Windows 7 x64, but compiling 32-bit DMD. DMD compiles
fine, but the linker warns about a "Warning 9: Unknown Option :
LA". After that, when trying to compile Druntime, DMD chokes
with this error:
"Assertion Failure: 'impl' on
On Thursday, 13 February 2014 at 14:30:41 UTC, Regan Heath wrote:
Don't get me wrong, counting the elements as you iterate over
them is useful, but it isn't the index into the range you're
likely after.
Nope, not what I am after. If I was, I'd iterate over the
original range instead or keep
Meta:
alias list1 = Cons!(Three, Cons!(Two, Cons!(Four, Cons!(One,
Nil;
alias numlHead(L: Cons!(a, b), a, b) = a;
alias numlTail(L: Cons!(a, b), a, b) = b;
But the compiler is complaining loudly about a mismatch:
/d43/f234.d(39): Error: template instance numlHead!(list1) does
not matc
Coming back to this after a few days. I got a bit farther, but
I'm running into trouble with the template args pattern matching.
I'd like to turn this code:
list1 :: Cons Three (Cons Two (Cons Four (Cons One Nil)))
list1 = undefined
numlHead :: Cons a b -> a
numlHead = const undefined
nu
On 2/13/2014 8:09 PM, Meta wrote:
I'm using Windows 7 x64, but compiling 32-bit DMD. DMD compiles fine,
but the linker warns about a "Warning 9: Unknown Option : LA". After
that, when trying to compile Druntime, DMD chokes with this error:
Sounds like you're using an outdated OPTLINK. The /LA
On Thu, 13 Feb 2014 19:06:45 -0500, timotheecour
wrote:
On Thursday, 13 February 2014 at 23:56:35 UTC, Timothee Cour
wrote:
how to iterate over an AA by key-value pair (tuple)?
use case:
avoid interrupting UFCS chains, eg:
foo.generate_aa.byKeyValue.filter!(a=>a[0].isLower).map!(a=>a[1]) ...
I'm using Windows 7 x64, but compiling 32-bit DMD. DMD compiles
fine, but the linker warns about a "Warning 9: Unknown Option :
LA". After that, when trying to compile Druntime, DMD chokes with
this error:
"Assertion Failure: 'impl' on line 4930 in file 'mtype.c'".
I looked in the file, but a
timotheecour:
is there anything more efficient than this?
auto byKeyValue(T)(T a)if(isAssociativeArray!T){
return a.byKey.map!(b=>tuple(b, a[b]));
}
zipping byKey and byValue could be faster, but there's no
guarantee its result is correct.
Bye,
bearophile
On Thursday, 13 February 2014 at 23:56:35 UTC, Timothee Cour
wrote:
how to iterate over an AA by key-value pair (tuple)?
use case:
avoid interrupting UFCS chains, eg:
foo.generate_aa.byKeyValue.filter!(a=>a[0].isLower).map!(a=>a[1])
...
of course I could roll my own function but I was wondering
is there anything more efficient than this?
auto byKeyValue(T)(T a)if(isAssociativeArray!T){
return a.byKey.map!(b=>tuple(b, a[b]));
}
On Thu, Feb 13, 2014 at 3:56 PM, Timothee Cour wrote:
> how to iterate over an AA by key-value pair (tuple)?
> use case:
> avoid interrupting UFCS chains, eg
how to iterate over an AA by key-value pair (tuple)?
use case:
avoid interrupting UFCS chains, eg:
foo.generate_aa.byKeyValue.filter!(a=>a[0].isLower).map!(a=>a[1]) ...
of course I could roll my own function but I was wondering if there's
already a way.
On Thursday, 13 February 2014 at 20:56:32 UTC, Frustrated wrote:
how efficient is ufcs? It seems like it would be very slow in
general and way better to manually do the code. I wonder if
anyone has done any tests?
LDC and GDC are pretty darn good at inlining these UFCS chains,
but the yielded
On Monday, 10 February 2014 at 10:41:06 UTC, Russel Winder wrote:
On Mon, 2014-02-10 at 09:16 +, Gary Willoughby wrote:
On Monday, 10 February 2014 at 03:14:31 UTC, Jonathan Dunlap
wrote:
> (disclaimer: I'm new around here)
> Is it possible to cycle backwards? If not, what's the best
> app
On Thursday, 13 February 2014 at 20:40:21 UTC, Tobias Pankrath
wrote:
On Monday, 10 February 2014 at 03:14:31 UTC, Jonathan Dunlap
wrote:
(disclaimer: I'm new around here)
Is it possible to cycle backwards? If not, what's the best
approach?
Example of some ideal "takeBack" function:
data = cy
On Monday, 10 February 2014 at 03:14:31 UTC, Jonathan Dunlap
wrote:
(disclaimer: I'm new around here)
Is it possible to cycle backwards? If not, what's the best
approach?
Example of some ideal "takeBack" function:
data = cycle([1,2,3][])
take(data, 4) is [1,2,3,1][]
takeBack(data, 4) would be
On Thu, 2014-02-13 at 18:03 +, bearophile wrote:
[…]
> Take also a look at itertools.cycle.
How about this:
#! /usr/bin/env py.test-3.3
from itertools import cycle, islice
data = [1, 2, 3]
def test_forward():
assert tuple
On Thu, 2014-02-13 at 18:03 +, bearophile wrote:
[…]
> Take also a look at itertools.cycle.
Indeed. I keep forgetting about itertools when rushed, which is a
definite error.
--
Russel.
=
Dr Russel Winder t: +44
Russel Winder:
I had a quick go at doing a Python 3 version using PyTest:
def provide(sourceSequence, resultLength):
return (sourceSequence[i % len(sourceSequence)] for i in
range(resultLength))
def provideReverse(sourceSequence, resultLength):
sourceLength = len(sourceSequence)
On Monday, 10 February 2014 at 03:14:31 UTC, Jonathan Dunlap
wrote:
(disclaimer: I'm new around here)
Is it possible to cycle backwards? If not, what's the best
approach?
Example of some ideal "takeBack" function:
data = cycle([1,2,3][])
take(data, 4) is [1,2,3,1][]
takeBack(data, 4) would be
On Thursday, 13 February 2014 at 14:45:44 UTC, bearophile wrote:
Stephan Schiffels:
It would be actually easy to implement chunks without the
"save" function, by using an internal buffer, which would
however make this algorithm's memory burden linear in the
chunk size. Would that be acceptabl
On Thursday, 13 February 2014 at 17:12:28 UTC, Dicebot wrote:
On Thursday, 13 February 2014 at 16:57:19 UTC, John Colvin
wrote:
Don't you mean const/immutable fields with initialisers don't
become instance fields? Or is this actually as strange as it
sounds?
Yes, it is legacy behavior (== bug
On Thursday, 13 February 2014 at 16:57:19 UTC, John Colvin wrote:
Don't you mean const/immutable fields with initialisers don't
become instance fields? Or is this actually as strange as it
sounds?
Yes, it is legacy behavior (== bug) that persisted since D1 days
and was addressed only recently
On Thursday, 13 February 2014 at 16:52:58 UTC, bearophile wrote:
Andre:
could you have a look whether this is a bug with tupleof?
In case you have a const string with a default value,
the attribute is not in the tupleof list.
struct A {
const string a = "abc";
string d;
}
void
Am 13.02.2014 17:52, schrieb bearophile:
Andre:
could you have a look whether this is a bug with tupleof?
In case you have a const string with a default value,
the attribute is not in the tupleof list.
struct A {
const string a = "abc";
string d;
}
void main(){
assert(A().tupleof.
Andre:
could you have a look whether this is a bug with tupleof?
In case you have a const string with a default value,
the attribute is not in the tupleof list.
struct A {
const string a = "abc";
string d;
}
void main(){
assert(A().tupleof.length == 2); // fails -> leng
Am 13.02.2014 17:42, schrieb Tobias Pankrath:
On Thursday, 13 February 2014 at 16:37:20 UTC, Andre wrote:
Hi,
could you have a look whether this is a bug with tupleof?
In case you have a const string with a default value,
the attribute is not in the tupleof list.
struct A {
const string a
On Thursday, 13 February 2014 at 16:37:20 UTC, Andre wrote:
Hi,
could you have a look whether this is a bug with tupleof?
In case you have a const string with a default value,
the attribute is not in the tupleof list.
struct A {
const string a = "abc";
string d;
}
void main(){
Hi,
could you have a look whether this is a bug with tupleof?
In case you have a const string with a default value,
the attribute is not in the tupleof list.
struct A {
const string a = "abc";
string d;
}
void main(){
assert(A().tupleof.length == 2); // fails -> length =
Stephan Schiffels:
It would be actually easy to implement chunks without the
"save" function, by using an internal buffer, which would
however make this algorithm's memory burden linear in the chunk
size. Would that be acceptable?
I think it's acceptable. But perhaps you need to add one more
On Wed, 12 Feb 2014 21:01:58 -, Jesse Phillips
wrote:
On Wednesday, 12 February 2014 at 10:52:13 UTC, Regan Heath wrote:
On Tue, 11 Feb 2014 19:48:40 -, Jesse Phillips
wrote:
On Tuesday, 11 February 2014 at 10:10:27 UTC, Regan Heath wrote:
Things like this should "just work"..
On Wed, 12 Feb 2014 11:08:57 -, Jakob Ovrum
wrote:
On Wednesday, 12 February 2014 at 10:44:57 UTC, Regan Heath wrote:
Ahh.. so this is a limitation of the range interface. Any plans to
"fix" this?
R
Did my original reply not arrive? It is the first reply in the thread...
It did,
On Thursday, 13 February 2014 at 12:43:00 UTC, bearophile wrote:
Stanislav Blinov:
Yup. And given how Walter and Andrei don't like breaking code,
we should just previde enough usage so it would become a rule
too :D
That's not the rational way a language should be designed.
Tester Driven Dev
Stanislav Blinov:
Yup. And given how Walter and Andrei don't like breaking code,
we should just previde enough usage so it would become a rule
too :D
That's not the rational way a language should be designed. Tester
Driven Development
(http://en.wikipedia.org/wiki/Tester_driven_development
On Thursday, 13 February 2014 at 12:30:29 UTC, bearophile wrote:
Tobias Pankrath:
That byKey and byValue adhere to the same order is not backed
up by the documenation, I suppose?
Right. It's a bet (unlike in Python, that has this rule in the
docs).
Yup. And given how Walter and Andrei don'
Tobias Pankrath:
That byKey and byValue adhere to the same order is not backed
up by the documenation, I suppose?
Right. It's a bet (unlike in Python, that has this rule in the
docs).
Bye,
bearophile
Is there any other way to create a range of simple (key,value)
pairs for the array, but needs to allocate (hash.keys return
an array of keys) and then again look up every key.
import std.algorithm : zip;
import std.traits: isAssociativeArray;
auto byKeyValuePair(AA)(AA aa) if (isAssociativ
On Thursday, 13 February 2014 at 11:00:17 UTC, Tobias Pankrath
wrote:
I've got a hash map T[][T] with keys of T and values of T[].
For some reason, I'll need a range of tuples (t1, t2), where t1
is a key and t2 is an element of the array t1 maps to. To have
them in order would be great, but is
On Thursday, 13 February 2014 at 11:25:09 UTC, Nordlöw wrote:
Is there some trait in Phobos to check if each element of a
type tuple fulfil a type predicate?
I want this in a variadic function limiter to assert that all
its arguments function fulfils a predicate.
Something like:
void f(T...
Is there some trait in Phobos to check if each element of a type
tuple fulfil a type predicate?
I want this in a variadic function limiter to assert that all its
arguments function fulfils a predicate.
Something like:
void f(T...)(T args) if (All!(T,SomePredicate))
{
...
}
tcak:
I didn't see any information about position of keywords in
documentation.
It's a compiler bug. And it's in Bugzilla since some years.
Bye,
bearophile
I've got a hash map T[][T] with keys of T and values of T[]. For
some reason, I'll need a range of tuples (t1, t2), where t1 is a
key and t2 is an element of the array t1 maps to. To have them in
order would be great, but is not necessary.
I just wrote my own range type and it works. But I won
On Thursday, 31 October 2013 at 10:35:54 UTC, Stephan Schiffels
wrote:
On Wednesday, 30 October 2013 at 20:43:54 UTC, qznc wrote:
On Wednesday, 30 October 2013 at 00:20:12 UTC, Stephan
Schiffels wrote:
Hi,
I'd like a version of std.range.chunk that does not require
the range to have the "leng
On Thursday, 13 February 2014 at 08:57:43 UTC, John Colvin wrote:
On Thursday, 13 February 2014 at 07:32:24 UTC, Joseph Cassman
wrote:
Looks like you still have a dmd.conf hanging around from a
previous installation. See
http://dlang.org/dmd-linux.html#dmd_conf
My guess would be in /etc
Th
The following two function definitions. First one gives error,
second one works. Can anyone tell me the difference between
putting the "shared" keyword at the end of definition, and before
static.
// this gives error message
// Error: semicolon expected following function declaration
private s
On Thursday, 13 February 2014 at 07:32:24 UTC, Joseph Cassman
wrote:
I created a straightforward script for x86_64 Linux which comes
directly from the wiki: http://wiki.dlang.org/Building_DMD. The
script is to automate pulling down a development snapshot of
the ecosystem and build + install it.
On 2/13/2014 2:55 AM, Nick Sabalausky wrote:
But if I use the RDMD/DMD *both* from DMD 2.065-b3
then...I dunno, either the exe doesn't get actually get rebuilt even
with --force, or maybe it does but then runs an older copy of the exe,
or something screwy like that. I need to look into that more.
On 2/12/2014 6:14 PM, Sean Kelly wrote:
On Wednesday, 12 February 2014 at 22:42:45 UTC, Nick Sabalausky
wrote:
Tried on both 2.064.2 and 2.065-b3.
Could it be that the custom toString just doesn't get run for static
exceptions?
It should. I'm not entirely sure why it isn't working. For
ref
57 matches
Mail list logo