On Monday, 17 July 2017 at 11:07:35 UTC, Anton Fediushin wrote:
Hello! What is the best way of rewriting this code in idiomatic
D manner?
--
foreach(a; ["foo", "bar"]) {
foreach(b; ["baz", "foz", "bof"]) {
foreach(c; ["FOO", "BAR"]) {
// Some operations on a, b and c
}
}
}
On Tuesday, 18 July 2017 at 02:21:59 UTC, Enjoys Math wrote:
DMD32 D Compiler v2.074.1
import std.file;
void main() {
string bigInput = readText("input.txt");
}
The file is 7 MB of ascii text, don't know if that matters...
Should I upgrade versions?
I wonder if it thinks there is a BOM
DMD32 D Compiler v2.074.1
import std.file;
void main() {
string bigInput = readText("input.txt");
}
The file is 7 MB of ascii text, don't know if that matters...
Should I upgrade versions?
On Mon, Jul 17, 2017 at 10:32:14PM +, Nordlöw via Digitalmars-d-learn wrote:
> On Monday, 17 July 2017 at 20:01:41 UTC, H. S. Teoh wrote:
[...]
> > result[offset .. offset + a.length] = a[];
>
> This slice assignment doesn't support conversion between different
> element-ty
On Monday, 17 July 2017 at 20:28:12 UTC, Nordlöw wrote:
Made some adjustments with working unittest and put it up on
https://github.com/nordlow/phobos-next/blob/master/src/algorithm_ex.d#L2467
Moved here
https://github.com/nordlow/phobos-next/blob/master/src/array_ex.d#L2765
On Monday, 17 July 2017 at 20:01:41 UTC, H. S. Teoh wrote:
OK, here's an actual, compilable, runnable version:
import std.algorithm : sum;
import std.meta : allSatisfy, staticMap;
import std.range : only;
import std.traits : CommonType, isStaticArray;
ali
On Monday, 17 July 2017 at 20:53:36 UTC, H. S. Teoh wrote:
See the working implementation in my latest post on this
thread. That version supports CommonType, and works correctly
with empty tuples as well.
T
Thanks.
On Mon, Jul 17, 2017 at 08:28:12PM +, Nordlöw via Digitalmars-d-learn wrote:
[...]
> I had to special-case foreach body for `i == 0` since `sumOfLengths`
> couldn't instantiate with empty tuple `()`.
>
> Further, should `concat` support `CommonType`? That is, should
>
> int[2] x = [1, 2];
Is there a known limitation in profiling these or am I doing
something wrong?
When I try to run my application from VisualD (x64 build) with
-profile switch I just get Access Violation reported on WinMain
function (actual declaration, it doesn't enter its body). If I
build it with dub build -
On Monday, 17 July 2017 at 20:10:31 UTC, H. S. Teoh wrote:
On Mon, Jul 17, 2017 at 08:11:03PM +, Nordlöw via
Digitalmars-d-learn wrote: [...]
Does this have a place in Phobos?
Never know till you try. :-D
If so,
- under what name: append, concat or cat?
I'd vote for concat.
- wher
On Mon, Jul 17, 2017 at 08:11:03PM +, Nordlöw via Digitalmars-d-learn wrote:
[...]
> Does this have a place in Phobos?
Never know till you try. :-D
> If so,
>
> - under what name: append, concat or cat?
I'd vote for concat.
> - where: std.algorithm or std.array?
std.array, IMO, since it
On Monday, 17 July 2017 at 19:11:26 UTC, H. S. Teoh wrote:
Hmm, since we already have sumOfLengths available at
compile-time, what about:
T[sumOfLengths!StaticArrays]
append(StaticArrays...)(StaticArrays arrays)
if (allSatisfy!(isStaticArray, StaticArrays))
{
OK, here's an actual, compilable, runnable version:
import std.algorithm : sum;
import std.meta : allSatisfy, staticMap;
import std.range : only;
import std.traits : CommonType, isStaticArray;
alias Elem(A : E[n], E, size_t n) = E;
enum Length(A) =
On Monday, 17 July 2017 at 18:54:31 UTC, Stefan Koch wrote:
we have special code in the compiler to optimize a ~ b ~ c.
Interesting, can you elaborate on what you mean with "optimize".
In that case, is there a reason why
int x[2];
int y[2];
int z[x.length + y.length] = x ~ y;
isn
On Monday, 17 July 2017 at 18:54:31 UTC, Stefan Koch wrote:
So all you need to do make it so
auto cat(T[]...)(T args)
{
T[] result;
mixin(() {
string mix = `result = `;
foreach(i;args.length)
{
mix ~= `args[` ~ itos(i) ~ `] ~`;
}
mix[$-1] = ';';
On Mon, Jul 17, 2017 at 12:01:48PM -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
[...]
> template sumOfLengths(A...)
> if (A.length > 0)
> {
> static if (A.length == 1)
> enum sumOfLengths = A[0].length;
> else
>
On Mon, Jul 17, 2017 at 12:01:48PM -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
[...]
> T[sumOfLengths!StaticArrays] append(StaticArrays...)(StaticArrays
> arrays)
> if (/* insert static array constraints here */)
> {
> typeof(return) result = void;
>
On Mon, Jul 17, 2017 at 05:38:23PM +, Nordlöw via Digitalmars-d-learn wrote:
> I'm want to define a specialization of `append()` that takes only
> static arrays as inputs and returns a static array being the sum of
> the lengths of the inputs.
>
> Have anybody already implemented this?
>
> If
On 07/17/2017 08:35 PM, Nordlöw wrote:
Thanks, but I'm talking about the variadic case where the number of
input arguments are unknown (>= 2) where the function header looks
something like
import std.traits : allSatisfy, isStaticArray;
auto append(R, Args...)(auto ref Args args)
if (args
On Monday, 17 July 2017 at 18:38:16 UTC, Nordlöw wrote:
On Monday, 17 July 2017 at 17:46:42 UTC, ag0aep6g wrote:
int[n + m] result = a ~ b;
Further, the expression `a ~ b` here will allocate and create a
copy on the GC-heap before writing `result`.
Maybe LDC optimizes away this now or i
On Monday, 17 July 2017 at 17:38:23 UTC, Nordlöw wrote:
I'm want to define a specialization of `append()` that takes
only static arrays as inputs and returns a static array being
the sum of the lengths of the inputs.
Have anybody already implemented this?
If not, I'm specifically interested i
On Monday, 17 July 2017 at 17:46:42 UTC, ag0aep6g wrote:
int[n + m] result = a ~ b;
Further, the expression `a ~ b` here will allocate and create a
copy on the GC-heap before writing `result`.
Maybe LDC optimizes away this now or in the future but DMD cannot.
Yeah I know, kind of dumb b
On Monday, 17 July 2017 at 17:46:42 UTC, ag0aep6g wrote:
Like so?
int[n + m] append(size_t n, size_t m)(int[n] a, int[m] b)
{
int[n + m] result = a ~ b;
return result;
}
Thanks, but I'm talking about the variadic case where the number
of input arguments are unknown (>= 2) where the fu
On Monday, 17 July 2017 at 17:57:14 UTC, Enjoys Math wrote:
I made a console app the other day and there were build options
present.
In the build options I had to specify the dmd2 executable
directly. Then it worked (but that's another error).
Today there are no build options! I tried crea
I made a console app the other day and there were build options
present.
In the build options I had to specify the dmd2 executable
directly. Then it worked (but that's another error).
Today there are no build options! I tried creating a regular
console app and a GDC/DMD console app.
On 07/17/2017 07:38 PM, Nordlöw wrote:
I'm want to define a specialization of `append()` that takes only static
arrays as inputs and returns a static array being the sum of the lengths
of the inputs.
Have anybody already implemented this?
If not, I'm specifically interested in how to most con
I'm want to define a specialization of `append()` that takes only
static arrays as inputs and returns a static array being the sum
of the lengths of the inputs.
Have anybody already implemented this?
If not, I'm specifically interested in how to most conveniently
infer the length (as an enum)
On 17/07/2017 2:47 PM, Zaheer Ahmed wrote:
I am Developing an Operating System in D Language and when want to
Develop my writeln("Zaheer"); function, I pass String "Zaheer" and when
receive, it says Error
Error: function kernel.dwriteln (char* str) is not callable using
argument types (string)
I am Developing an Operating System in D Language and when want
to Develop my writeln("Zaheer"); function, I pass String "Zaheer"
and when receive, it says Error
Error: function kernel.dwriteln (char* str) is not callable using
argument types (string)
I Tried to cast but still stuck. In C and C+
As for the problem itself, it can be solved without finding
connected components. I won't post the solution right away
because it is potentially a spoiler. See
http://codeforces.com/blog/entry/53268 for problem analysis
(828B) and
http://codeforces.com/contest/828/submission/28637184 for an
On Monday, 17 July 2017 at 11:55:47 UTC, Anton Fediushin wrote:
Thank you! I knew it is in the library! So, `parallel` will
work just fine with this function, isn't it?
Yes
On Monday, 17 July 2017 at 11:32:45 UTC, Sebastiaan Koppe wrote:
On Monday, 17 July 2017 at 11:07:35 UTC, Anton Fediushin wrote:
Hello! What is the best way of rewriting this code in
idiomatic D manner?
https://dlang.org/phobos/std_algorithm_setops.html#.cartesianProduct
Thank you! I knew it
On Monday, 17 July 2017 at 07:14:26 UTC, Andrea Fontana wrote:
Probably using ndslice library could help you!
Unfortunately, that's not possible on most online contest
platforms like Codeforces. For each programming language and
compiler available, only the most basic package is usually
in
On Sunday, 16 July 2017 at 21:50:19 UTC, kerdemdemir wrote:
Process(row-1,column-1, maxrow, maxcolumn);
Process(row,column-1, maxrow, maxcolumn);
Process(row+1,column-1, maxrow, maxcolumn);
Process(ro
On Monday, 17 July 2017 at 11:07:35 UTC, Anton Fediushin wrote:
Hello! What is the best way of rewriting this code in idiomatic
D manner?
https://dlang.org/phobos/std_algorithm_setops.html#.cartesianProduct
Hello! What is the best way of rewriting this code in idiomatic D
manner?
--
foreach(a; ["foo", "bar"]) {
foreach(b; ["baz", "foz", "bof"]) {
foreach(c; ["FOO", "BAR"]) {
// Some operations on a, b and c
}
}
}
--
Every array has at least 1 element, and adding/removing n
Could anyone show me how to debug in vscode with mago-mi?
I have installed vscode with Native Debug, SDLang. I have tried
dlang-vscode and code-d.
My tasks.json:
{
"version": "2.0.0",
"command": "dub",
"type": "shell",
"presentation": {
"echo": true,
"reveal": "
On Sunday, 16 July 2017 at 10:37:39 UTC, kerdemdemir wrote:
My goal is to find connected components in a 2D array for
example finding connected '*'
chars below.
You can also use a queue to avoid recursion that should improve
performances and readibility.
Probably using ndslice library could
38 matches
Mail list logo