On Sun, Oct 11, 2020 at 01:26:13PM +, Alaindevos via Digitalmars-d-learn
wrote:
> Sidenote, sort also not works with static arrays.
Just slice it with [].
T
--
I think the conspiracy theorists are out to get us...
Sidenote, sort also not works with static arrays.
gorithm.iteration.sum(R, E)(R r, E seed) if
(isInputRange!R && !isInfinite!R && is(typeof(seed = seed +
r.front)))
So a dynamic array works just fine. In fact, if I uncomment
the line in question the program compiles and outputs the
correct value (for a2). Why does "sum" not work
On Thursday, 1 August 2019 at 21:26:10 UTC, Matt wrote:
Anyone have any other thoughts?
I tried to simplify your example a little bit:
import std.stdio;
import std.range;
import std.algorithm;
auto myFilter(R1, R2)(R1 a, R2 b)
{
return a.filter!(c => c==b.front);
}
struct A
{
int[]
On Thursday, 1 August 2019 at 21:12:51 UTC, ag0aep6g wrote:
`choose`'s parameters aren't lazy. So the second argument is
evaluated even when `previous is null`. That means
`intervalRange` is called on a null `previous`. And that fails,
of course, because `intervalRange` can't access `starts`
On 01.08.19 22:23, Matt wrote:
Version 4 does not work when PairedA.previous is null. I'd love to
understand why.
[...]
auto myFilter(R1, R2)(R1 a, R2 b)
{
import std.algorithm : filter, canFind;
return a.filter!(c => b.canFind(c));
}
struct A
{
uint[] starts, stops;
I'm having some trouble with a "Program exited with code
-1073741819" error in some code I'm writing and I would
appreciate any help/insight.
The problem stems from some incompatibility between the Phobos
function "choose" and the template function "myFilter" which
returns a range. The code
On Tuesday, 31 July 2018 at 08:42:28 UTC, Simen Kjærås wrote:
From https://dlang.org/spec/function.html#pseudo-member:
"A free function can be called with a syntax that looks as if
the function were a member function of its first parameter
type."
[...]
Thanks a lot Simen :)
On Tuesday, 31 July 2018 at 08:28:01 UTC, Ky-Anh Huynh wrote:
Hi,
Can I define a new quick function to use inside a unittest
block?
I have the following code:
[code]
auto foo(string[] sta) {
return sta;
}
auto bar(string[] sta) {
return sta;
}
auto h(string[] sta) {
return
dmd version that I'm using:
$ dmd --version
DMD64 D Compiler v2.081.1-dirty
Copyright (C) 1999-2018 by The D Language Foundation, All Rights
Reserved written by Walter Bright
Hi,
Can I define a new quick function to use inside a unittest block?
I have the following code:
[code]
auto foo(string[] sta) {
return sta;
}
auto bar(string[] sta) {
return sta;
}
auto h(string[] sta) {
return sta.foo.bar;
}
unittest {
import std.format;
auto f = (string[] sta)
On Friday, 1 January 2016 at 14:00:41 UTC, TheDGuy wrote:
writeln("Which number should i guess?");
string input = readln();
int i = to!int(input);
You fell for the C# syntax like me...
According to Ahli. You have to use the old C way of doing it with
readf.
On Friday, 1 January 2016 at 14:00:41 UTC, TheDGuy wrote:
writeln("Which number should i guess?");
string input = readln();
int i = to!int(input);
The solution is that readln() returns a string that also contains
the newline
this can be solved by easily stripping the
On Friday, 1 January 2016 at 14:20:26 UTC, Tobi G. wrote:
The solution is that readln() returns a string that also
contains the newline
this can be solved by easily stripping the newline off
import std.string;
int i = to!int(input.strip);
Sorry my bad english.. i wrote solution but meant
On Friday, 1 January 2016 at 14:47:20 UTC, TheDGuy wrote:
On Friday, 1 January 2016 at 14:29:34 UTC, Tobi G. wrote:
On Friday, 1 January 2016 at 14:20:26 UTC, Tobi G. wrote:
The solution is that readln() returns a string that also
contains the newline
this can be solved by easily stripping
writeln("Which number should i guess?");
string input = readln();
int i = to!int(input);
On Friday, 1 January 2016 at 14:29:34 UTC, Tobi G. wrote:
On Friday, 1 January 2016 at 14:20:26 UTC, Tobi G. wrote:
The solution is that readln() returns a string that also
contains the newline
this can be solved by easily stripping the newline off
import std.string;
int i =
On Friday, 1 January 2016 at 15:06:53 UTC, bachmeier wrote:
I've battled with a few times, not having any idea what was
going on. I now almost automatically use strip when it's not
working.
This is one of the most frequently asked questions by new users..
I added a tip to my new docs:
On Friday, 1 January 2016 at 15:16:36 UTC, Adam D. Ruppe wrote:
On Friday, 1 January 2016 at 15:06:53 UTC, bachmeier wrote:
I've battled with a few times, not having any idea what was
going on. I now almost automatically use strip when it's not
working.
This is one of the most frequently
On Friday, 1 January 2016 at 17:00:23 UTC, TheDGuy wrote:
If i had known that blog existed. I think your example at the
end of the page explains the problem really well.
Thanks!
I just wrote that example in response to this thread :P (the
overall thing there is something i started last week
On Friday, 1 January 2016 at 15:16:36 UTC, Adam D. Ruppe wrote:
On Friday, 1 January 2016 at 15:06:53 UTC, bachmeier wrote:
I've battled with a few times, not having any idea what was
going on. I now almost automatically use strip when it's not
working.
This is one of the most frequently
ge!R && !isInfinite!R && is(typeof(seed = seed +
r.front)))
So a dynamic array works just fine. In fact, if I uncomment the
line in question the program compiles and outputs the correct
value (for a2). Why does "sum" not work on static arrays?
Regards
So that
& is(typeof(seed = seed + r.front)))
So a dynamic array works just fine. In fact, if I uncomment the line in
question the program compiles and outputs the correct value (for a2).
Why does "sum" not work on static arrays?
Regards
Because static array aren't ranges, but dynamic ones are
seed + r.front)))
So a dynamic array works just fine. In fact, if I uncomment the
line in question the program compiles and outputs the correct
value (for a2). Why does "sum" not work on static arrays?
Regards
On Sunday, 6 December 2015 at 12:27:49 UTC, cym13 wrote:
A static array is a value type so it is passed by value to
functions.
Oh, right, I totally forgot about that. Thank you for reminding
me.
And yes, I was not planning on doing that. I just have a local
fixed-size array that I wanted to
void func( int c )
{
ubyte a;
a = cast(ubyte)c + cast(ubyte)c;
}
dmd v2.065 complains about:
test.d(5): Error: cannot implicitly convert expression
(cast(int)cast(ubyte)c + cast(int)cast(ubyte)c) of type int to
ubyte
As far as I can tell, adding two values of the same type should
the result of ubyte + ubyte is int I believe.
Try;
void func( int c )
{
ubyte a;
a = cast(ubyte)(cast(ubyte)c + cast(ubyte)c);
}
On Wed, 17 Sep 2014 13:20:13 +
Shachar via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:
From http://dlang.org/type, under Usual Arithmetic Conversions:
4. Else the integer promotions are done on each operand, followed
by:
1. If both are the same type, no more
On 17/09/14 16:32, ketmar via Digitalmars-d-learn wrote:
On Wed, 17 Sep 2014 13:20:13 +
Shachar via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:
From http://dlang.org/type, under Usual Arithmetic Conversions:
4. Else the integer promotions are done on each operand,
Because of overflow.
On Wednesday, 17 September 2014 at 13:36:42 UTC, Shachar Shemesh
wrote:
On 17/09/14 16:32, ketmar via Digitalmars-d-learn wrote:
On Wed, 17 Sep 2014 13:20:13 +
Shachar via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com
wrote:
From http://dlang.org/type,
On Wed, 17 Sep 2014 16:36:41 +0300
Shachar Shemesh via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
I don't understand. Why is this behavior preferrable to the one
outlined by the specs?
'cause C does exactly this. there is no reason to confuse people with C
background by
http://www.drdobbs.com/tools/value-range-propagation/229300211
On Wednesday, 17 September 2014 at 13:20:15 UTC, Shachar wrote:
On Wednesday, 17 September 2014 at 13:03:05 UTC,
flamencofantasy wrote:
the result of ubyte + ubyte is int I believe.
Try;
void func( int c )
{
ubyte a;
a = cast(ubyte)(cast(ubyte)c + cast(ubyte)c);
}
From
toUTF16 can take a char[], wchar[] or dchar[].
But toUTF16z can only take a char[]. Why?
I'm storing some text as dchar[] internally and have to pass it to WinAPI
Unicode functions which expect null-terminated UTF16 strings. But toUTF16z only
works with char[] for some reason.
I guess this should do it:
const(wchar)* toUTF16z(in dchar[] s)
{
return (toUTF16(s) ~ \000).ptr;
}
35 matches
Mail list logo