On Monday, 25 May 2015 at 15:46:54 UTC, Dennis Ritchie wrote:
On Monday, 25 May 2015 at 15:06:45 UTC, Alex Parrill wrote:
Hint: Use `cartesianProduct` [1] with three iota ranges to
replace the foreachs, and `filter` to replace the if
[1]
Hi,
Is it possible to write such a construction that could push
immediately to a conditional statement without using nested
loops? Ie organize search directly in the iterator if provided by
a map / each / iota and other support functions.
Ie I want to write this code shorter :)
import
On Monday, 25 May 2015 at 15:06:45 UTC, Alex Parrill wrote:
Hint: Use `cartesianProduct` [1] with three iota ranges to
replace the foreachs, and `filter` to replace the if
[1]
http://dlang.org/phobos/std_algorithm_setops.html#.cartesianProduct
Thank you. Is it possible to replace the loop
On Monday, 25 May 2015 at 14:25:52 UTC, Dennis Ritchie wrote:
Hi,
Is it possible to write such a construction that could push
immediately to a conditional statement without using nested
loops? Ie organize search directly in the iterator if provided
by a map / each / iota and other support
On Monday, 25 May 2015 at 16:41:35 UTC, Meta wrote:
import std.algorithm;
import std.range;
import std.stdio;
void main()
{
const x = 12, y = 65, z = 50, s = 1435;
auto a = iota(0, x + 1);
cartesianProduct(a, a, a)
.filter!(i = i[0] * (y + 3 * z)
+ i[1] * (y + 2
On Monday, 25 May 2015 at 17:05:35 UTC, Dennis Ritchie wrote:
On Monday, 25 May 2015 at 16:41:35 UTC, Meta wrote:
import std.algorithm;
import std.range;
import std.stdio;
void main()
{
const x = 12, y = 65, z = 50, s = 1435;
auto a = iota(0, x + 1);
cartesianProduct(a, a, a)
On Monday, 25 May 2015 at 19:16:04 UTC, anonymous wrote:
On Monday, 25 May 2015 at 17:52:09 UTC, Dennis Ritchie wrote:
But why is the solution breaks down when `s = 1` ? :)
import std.stdio, std.algorithm, std.range;
int c;
const x = 12, y = 65, z = 50, s = 10;
Which is it, now? 4
On Monday, 25 May 2015 at 17:52:09 UTC, Dennis Ritchie wrote:
But why is the solution breaks down when `s = 1` ? :)
import std.stdio, std.algorithm, std.range;
int c;
const x = 12, y = 65, z = 50, s = 10;
Which is it, now? 4 or 5 zeros?
void solve(Range)(Range r) {
On Monday, 25 May 2015 at 17:19:27 UTC, Meta wrote:
`each` doesn't support braces. There are 4 ways to write a
function/delegate literal in D (with a few minor variations):
Short form:
function(int i) = i;
(int i) = i
(i) = i
i = i
Long form:
function(int i) { return i; }
(int i) { return i;