On 6/22/15 11:04 AM, Dennis Ritchie wrote:
Hi,
I recently came across the following code:
http://wiki.dlang.org/Higher_Order_Range_Pattern
I can't understand why the properties and methods of the structure are
called in the correct order.
Why are the property `back()` and the method
On Monday, 22 June 2015 at 15:25:12 UTC, Steven Schveighoffer
wrote:
On 6/22/15 11:04 AM, Dennis Ritchie wrote:
Hi,
I recently came across the following code:
http://wiki.dlang.org/Higher_Order_Range_Pattern
I can't understand why the properties and methods of the
structure are
called in
Does D has an equivalent to C#'s iterator
(https://msdn.microsoft.com/en-us/library/65zzykke.aspx)? if so,
where can I find it?
What I want is loop over a user-defined class/struct. In case of
C#, I just implement the IEnumerable and the GetEnumerator()
methods that's called by the foreach()
On 06/22/2015 09:37 AM, q66 wrote:
use opApply.
Yes. Additionally, an InputRange interface can be used:
http://ddili.org/ders/d.en/foreach_opapply.html
Ali
On 6/22/15 1:03 PM, Assembly wrote:
On Monday, 22 June 2015 at 16:52:15 UTC, Ali Çehreli wrote:
On 06/22/2015 09:37 AM, q66 wrote:
use opApply.
Yes. Additionally, an InputRange interface can be used:
http://ddili.org/ders/d.en/foreach_opapply.html
Ali
I was reading exaclty this page
On Monday, 22 June 2015 at 16:52:15 UTC, Ali Çehreli wrote:
On 06/22/2015 09:37 AM, q66 wrote:
use opApply.
Yes. Additionally, an InputRange interface can be used:
http://ddili.org/ders/d.en/foreach_opapply.html
Ali
I was reading exaclty this page that.
I've had implmented this
On Monday, 22 June 2015 at 13:49:21 UTC, Steven Schveighoffer
wrote:
On 6/20/15 10:26 PM, Yuxuan Shui wrote:
On Sunday, 21 June 2015 at 01:26:51 UTC, Adam D. Ruppe wrote:
On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote:
auto ref R) is indeed a template function, so I don't
On Monday, 22 June 2015 at 16:33:43 UTC, Assembly wrote:
Does D has an equivalent to C#'s iterator
(https://msdn.microsoft.com/en-us/library/65zzykke.aspx)? if
so, where can I find it?
What I want is loop over a user-defined class/struct. In case
of C#, I just implement the IEnumerable and
On Monday, 22 June 2015 at 08:18:08 UTC, Adrian Matoga wrote:
On Monday, 22 June 2015 at 06:09:48 UTC, Assembly wrote:
Does D has built-in stack structure (if so, which module?) or
should I implement it myself?
AFAIK there's no built-in, but std.array.Appender could be
easily wrapped in an
Hi,
I recently came across the following code:
http://wiki.dlang.org/Higher_Order_Range_Pattern
I can't understand why the properties and methods of the
structure are called in the correct order.
Why are the property `back()` and the method `popBack()` are not
called even once?
In general,
On 6/22/15 1:37 PM, Yuxuan Shui wrote:
On Monday, 22 June 2015 at 13:49:21 UTC, Steven Schveighoffer wrote:
On 6/20/15 10:26 PM, Yuxuan Shui wrote:
On Sunday, 21 June 2015 at 01:26:51 UTC, Adam D. Ruppe wrote:
On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote:
auto ref R) is
On Monday, 22 June 2015 at 17:09:16 UTC, Steven Schveighoffer
wrote:
On 6/22/15 1:03 PM, Assembly wrote:
[...]
TBH, opApply is much better suited to classes.
But in order to have multiple parameters with foreach by using
a range, you must return a tuple:
auto front() { import
On Monday, 22 June 2015 at 20:30:40 UTC, David DeWitt wrote:
I am getting an core.exception.InvalidMemoryOperationError@(0)
auto recs = f // Open for reading
.byLineCopy();
.array; //Here is where is appears
to be happening.
I have
On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote:
Try to compile this code snippet:
import std.traits;
template a(R) {
auto a(S)(auto ref R i) {
return cast(S)i*2;
}
}
template ReturnTypeEx(alias A, B) {
alias ReturnTypeEx = ReturnType!(A!B);
On Sunday, 21 June 2015 at 02:37:59 UTC, Yuxuan Shui wrote:
On Sunday, 21 June 2015 at 01:26:51 UTC, Adam D. Ruppe wrote:
On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote:
auto ref R) is indeed a template function, so I don't
understand.
But R is not a parameter on the function
Does D has built-in stack structure (if so, which module?) or
should I implement it myself?
On Sunday, 21 June 2015 at 23:25:47 UTC, Timothee Cour wrote:
Suppose I have:
import std.range;
auto a=iota(complex_expr_returning_3());
I'd like to have a function/trait/template/compiler magic that
takes
variable a and generates a string that can be mixed in to
represent the
type of a. The
On Monday, 22 June 2015 at 06:09:48 UTC, Assembly wrote:
Does D has built-in stack structure (if so, which module?) or
should I implement it myself?
AFAIK there's no built-in, but std.array.Appender could be easily
wrapped in an interface that makes thinking of it as stack easier:
struct
On Monday, 22 June 2015 at 18:07:36 UTC, Ali Çehreli wrote:
On 06/22/2015 10:03 AM, Assembly wrote:
foreach(int i, MyType p; places) {
but I get this error:
Error: cannot infer argument types, expected 1 argument, not 2
Yeah, the loop counter is automatic only for slices. You can
use
I am getting an core.exception.InvalidMemoryOperationError@(0)
auto recs = f // Open for reading
.byLineCopy();
.array; //Here is where is appears to
be happening.
I have narrowed it down to the .array. I am wondering if there
is
On Monday, 22 June 2015 at 18:44:22 UTC, Assembly wrote:
I'm using this, thanks for all. Can someone clarify how does
opApply() works? I assume it's called every iteration and as
opApply() has a loop does it means the number of iteration ran
actually is the ones from foreach() is 2*n where n
Where is your code found? InvalidMemoryOperationError usually
props up in code running from a destructor.
If the call to .array isn't in a destructor, it might also be
that the array is triggering a GC cycle... which calls something
in a destructor.
Since that's so commonly the cause I
On 06/22/2015 11:48 AM, Assembly wrote:
if my opApply() is defiend as the following:
int opApply(int delegate(ref int, ref T) del)
{
[...]
}
and called like:
foreach(int i, MyType p; places) {
isn't i the loop counter?
size_t is more natural but yes, that's it.
Ali
On 06/22/2015 10:03 AM, Assembly wrote:
foreach(int i, MyType p; places) {
but I get this error:
Error: cannot infer argument types, expected 1 argument, not 2
Yeah, the loop counter is automatic only for slices. You can use
'enumerate' for other types:
foreach (i, element;
On Tuesday, 16 June 2015 at 16:37:35 UTC, John Colvin wrote:
If you want really fast exponentiation of an array though, you
want to use SIMD. Something like http://www.yeppp.info would be
easy to use from D.
I've been looking into SIMD a little. It turns out that core.simd
only works for DMD
On Tuesday, 23 June 2015 at 02:34:17 UTC, Charles Hawkins wrote:
How do I find out what that means?
Many return codes have a meaning in the linux documentation:
http://www.tldp.org/LDP/abs/html/exitcodes.html#EXITCODESREF
(it lists them as unsigned, but you got a signed result. 128 ==
-1,
Thanks, Adam. I'm coming from OCaml and haven't seen a seg fault
in years. Didn't recognize it. :D Hopefully I can figure it out
from here.
On Tuesday, 23 June 2015 at 02:45:24 UTC, Adam D. Ruppe wrote:
128 == -1
I'm sorry, I need to stop posting these things without thinking.
-1 is actually 255 when you cast it, but I'm pretty sure the
shell just does that subtraction from 128 because of the signal
reservation codes. I stand
On Tuesday, 23 June 2015 at 03:29:14 UTC, Charles Hawkins wrote:
Thanks, Adam. I'm coming from OCaml and haven't seen a seg
fault in years. Didn't recognize it. :D Hopefully I can
figure it out from here.
Try to compile with either ldc or gdc and the -g flag, it should
give you a
On Monday, 22 June 2015 at 20:34:00 UTC, anonymous wrote:
On Monday, 22 June 2015 at 18:44:22 UTC, Assembly wrote:
I'm using this, thanks for all. Can someone clarify how does
opApply() works? I assume it's called every iteration and as
opApply() has a loop does it means the number of
My first attempt at a significant D program and I'm getting:
Error executing command run:
Program exited with code -11
How do I find out what that means?
What's a fast way to insert an element at index 0 of array? now
that the code is working I want to clean this:
void push(T val)
{
T[] t = new T[buffer.length + 1];
t[0] = val;
t[1 .. $] = buffer;
buffer = t;
}
I
On Tuesday, 23 June 2015 at 05:16:23 UTC, Assembly wrote:
What's a fast way to insert an element at index 0 of array? now
that the code is working I want to clean this:
void push(T val)
{
T[] t = new T[buffer.length + 1];
t[0] = val;
t[1
On Tuesday, 23 June 2015 at 05:16:23 UTC, Assembly wrote:
What's a fast way to insert an element at index 0 of array? now
that the code is working I want to clean this:
void push(T val)
{
T[] t = new T[buffer.length + 1];
t[0] = val;
t[1
This is my first project in D and I'm stumped. I have a library
and I want to link some test programs to it using dub. I've
tried a number of different things with no success. Can someone
point me to a dub project with examples in a similar situation
where maybe I can figure out what
On Monday, 22 June 2015 at 14:01:19 UTC, Charles Hawkins wrote:
This is my first project in D and I'm stumped. I have a
library and I want to link some test programs to it using dub.
I've tried a number of different things with no success. Can
someone point me to a dub project with examples
On 6/20/15 10:26 PM, Yuxuan Shui wrote:
On Sunday, 21 June 2015 at 01:26:51 UTC, Adam D. Ruppe wrote:
On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote:
auto ref R) is indeed a template function, so I don't understand.
But R is not a parameter on the function itself. It comes from
37 matches
Mail list logo