I agree with Andrei here, building hypercubes makes more sense, and feels like
it has more structure. It
also has the nice property that, once you've seen a (n+1)th element of any
range then you have already
explored the entire product of the first n elements of every range, kind of
like how
On 09/07/2010 02:43 AM, Peter Alexander wrote:
I agree with Andrei here, building hypercubes makes more sense, and feels like
it has more structure. It
also has the nice property that, once you've seen a (n+1)th element of any
range then you have already
explored the entire product of the
== Quote from Andrei Alexandrescu
Yah, per your follow-up post, it's a different problem. It's
also a much
more difficult one. I convinced myself crossProduct is
impossible to
implement if one input range and one infinite forward range are
simultaneously present. It works with any number of
Peter Alexander peter.alexander...@gmail.com wrote:
I must be missing something, because I don't understand how you
could possibly take the cross product of any number of infinite
ranges (other than to just return the range of (a[0], b[i]) for
all (infinitely many) i in b).
Note that I'm
Andrei Alexandrescu seewebsiteforem...@erdani.org wrote:
I convinced myself crossProduct is impossible to implement if one input
range and one infinite forward range are simultaneously present. It
works with any number of infinite forward ranges, and also with other
combinations. I couldn't
Simen kjaeraas simen.kja...@gmail.com wrote:
Special cases come for input ranges - I will not consider those. All
forward ranges can be treated the same, regardless of infiniteness.
Actually, input ranges make everything a lot easier - the best
solution is the brute-force stupid solution.
--
On 09/06/2010 06:51 AM, Peter Alexander wrote:
== Quote from Andrei Alexandrescu
Yah, per your follow-up post, it's a different problem. It's
also a much
more difficult one. I convinced myself crossProduct is
impossible to
implement if one input range and one infinite forward range are
Attached latest version. It bugs out with an infinite loop, and I'm too
tired to look more at it now.
--
Simen
autoRefTuple.d
Description: Binary data
combine.d
Description: Binary data
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article
We've discussed this before. Crosscartesian product of multiple infinite
ranges can be easily done by applying Cantor's trick for proving that
rational numbers are just as numerous than natural numbers. Google for
On 09/06/2010 04:34 PM, Philippe Sigaud wrote:
Which gives us: (0,0),(0,1),(1,0),(0,2),(1,1),(2,0),(0,3), ..
See the indices: sum of 0, then sum of 1, then sum of 2, ...
You never get stuck in an infinite line since these diagonal slices are finite.
I don't think iteration for constant index
Philippe Sigaud philippe.sig...@gmail.com wrote:
I guess the D syntax would be
auto x = amb([1,2,3]);
auto y =amb([4,5,6]);
x*y == 8; // forces desambiguation = the ambs explore the possibilities.
assert(x == amb([2]));
assert(y == amb([4]));
There is only one value left, no more ambiguity.
On Sun, Sep 5, 2010 at 12:00, Simen kjaeraas simen.kja...@gmail.com wrote:
Philippe Sigaud philippe.sig...@gmail.com wrote:
I guess the D syntax would be
auto x = amb([1,2,3]);
auto y =amb([4,5,6]);
x*y == 8; // forces desambiguation = the ambs explore the possibilities.
assert(x ==
On Sun, 05 Sep 2010 16:59:31 +0400, Philippe Sigaud
philippe.sig...@gmail.com wrote:
But the real challenge in the SO question is the 'going back in time'
part,
which I have trouble to understand : how can you modify x and y through a
multiplication and a comparison?
It can be done using
On 09/05/2010 07:59 AM, Philippe Sigaud wrote:
On Sun, Sep 5, 2010 at 12:00, Simen kjaeraas simen.kja...@gmail.com
mailto:simen.kja...@gmail.com wrote:
Philippe Sigaud philippe.sig...@gmail.com
mailto:philippe.sig...@gmail.com wrote:
I guess the D syntax would be
auto
2010/9/5 Denis Koroskin 2kor...@gmail.com
On Sun, 05 Sep 2010 16:59:31 +0400, Philippe Sigaud
philippe.sig...@gmail.com wrote:
But the real challenge in the SO question is the 'going back in time'
part,
which I have trouble to understand : how can you modify x and y through a
On Sun, Sep 5, 2010 at 15:56, Andrei Alexandrescu
seewebsiteforem...@erdani.org wrote:
equivalent to the problem:
auto solution = comp!([a,b], a*b == 8)([1,2,3], [4,5,6]);
solution is a range, in this case a one element range, containing only
[2,4].
I did a range comprehension maybe one
On Sun, Sep 5, 2010 at 16:30, Philippe Sigaud philippe.sig...@gmail.comwrote:
What you call crossProduct can be seen as zipWith!tuple(range, range2),
which
Scratch that. zipWith *is* mapping on n ranges in parallel.
On Sun, 05 Sep 2010 18:24:43 +0400, Philippe Sigaud
philippe.sig...@gmail.com wrote:
2010/9/5 Denis Koroskin 2kor...@gmail.com
On Sun, 05 Sep 2010 16:59:31 +0400, Philippe Sigaud
philippe.sig...@gmail.com wrote:
But the real challenge in the SO question is the 'going back in time'
part,
Denis Koroskin:
The code above should print:
state saved
state restored
(not tested)
On Windows, dmd 2.048, this code:
import std.c.stdio: puts;
version (Windows) {
alias int[16] jmp_buf;
extern (C) extern {
int setjmp(ref jmp_buf env);
void longjmp(ref jmp_buf
On Sun, 05 Sep 2010 19:17:55 +0400, bearophile bearophileh...@lycos.com
wrote:
Denis Koroskin:
The code above should print:
state saved
state restored
(not tested)
On Windows, dmd 2.048, this code:
import std.c.stdio: puts;
version (Windows) {
alias int[16] jmp_buf;
extern (C)
Denis Koroskin:
Turn main into an extern(C) int main() and it works.
This version:
import std.c.stdio: puts;
version (Windows) {
alias int[16] jmp_buf;
extern (C) extern {
int setjmp(ref jmp_buf env);
void longjmp(ref jmp_buf env, int value);
}
}
struct State {
On Sun, 05 Sep 2010 20:18:13 +0400, bearophile bearophileh...@lycos.com
wrote:
Denis Koroskin:
Turn main into an extern(C) int main() and it works.
This version:
import std.c.stdio: puts;
version (Windows) {
alias int[16] jmp_buf;
extern (C) extern {
int setjmp(ref
On 09/05/2010 09:30 AM, Philippe Sigaud wrote:
On Sun, Sep 5, 2010 at 15:56, Andrei Alexandrescu
seewebsiteforem...@erdani.org mailto:seewebsiteforem...@erdani.org
wrote:
equivalent to the problem:
auto solution = comp!([a,b], a*b == 8)([1,2,3], [4,5,6]);
solution is
Philippe Sigaud philippe.sig...@gmail.com wrote:
But the real challenge in the SO question is the 'going back in time'
part,
which I have trouble to understand : how can you modify x and y through a
multiplication and a comparison?
I believe this to be possible, though horrible and
On Sat, Sep 4, 2010 at 01:40, Simen kjaeraas simen.kja...@gmail.com wrote:
Simen kjaeraas simen.kja...@gmail.com wrote:
I believe this will only work with arrays as input. Either that, or I need
a way to make this work:
struct Foo( R ) if ( isForwardRange!R ) {
bool delegate(
== Quote from Nick Sabalausky (a...@a.a)'s article
Interesting thing, but devil's advocate: What would be the
uses/benefits of
that versus just having for each element versions of the
operators?
Well the obvious benefit is that you don't have to create all
those extra version -- you get them
Philippe Sigaud philippe.sig...@gmail.com wrote:
Hey, this question on SO makes for a good challenge:
http://stackoverflow.com/questions/3608834/is-it-possible-to-generically-implement-the-amb-operator-in-d
The amb operator does this:
amb([1, 2]) * amb([3, 4, 5]) == amb([3, 4, 5, 6, 8, 10])
On 02/09/10 05:38, Philippe Sigaud wrote:
Hey, this question on SO makes for a good challenge:
http://stackoverflow.com/questions/3608834/is-it-possible-to-generically-implement-the-amb-operator-in-d
It's great to see someone doing the first D discussion topic
with the [challenge] annotation.
== Quote from Simen kjaeraas (simen.kja...@gmail.com)'s article
Yes, very much so. However, Peter Alexander has misunderstood the
ambiguous operator.
Hey, I was just going by what the guy posted :) He mentioned
nothing of tuples, and his examples certainly didn't show any
tuples.
On Fri, Sep 3, 2010 at 19:51, Peter Alexander
peter.alexander...@gmail.comwrote:
== Quote from Simen kjaeraas (simen.kja...@gmail.com)'s article
Yes, very much so. However, Peter Alexander has misunderstood the
ambiguous operator.
Hey, I was just going by what the guy posted :) He
On Fri, Sep 3, 2010 at 16:30, Justin Johansson n...@spam.com wrote:
On 02/09/10 05:38, Philippe Sigaud wrote:
Hey, this question on SO makes for a good challenge:
http://stackoverflow.com/questions/3608834/is-it-possible-to-generically-implement-the-amb-operator-in-d
It's great to see
Peter Alexander peter.alexander...@gmail.com wrote:
== Quote from Simen kjaeraas (simen.kja...@gmail.com)'s article
Yes, very much so. However, Peter Alexander has misunderstood the
ambiguous operator.
Hey, I was just going by what the guy posted :) He mentioned
nothing of tuples, and his
Philippe Sigaud philippe.sig...@gmail.com wrote:
Now, the 'real'/intriguing/mind-bending amb operator (from the 60's) does
like the Haskell implementation linked in SO does: backtracking on the
results to avoid some condition. If someone is up to the challenge of
implementing it in D, great!
Simen kjaeraas simen.kja...@gmail.com wrote:
I believe this will only work with arrays as input. Either that, or I
need
a way to make this work:
struct Foo( R ) if ( isForwardRange!R ) {
bool delegate( ElementType!R ) bar;
Filter!( bar, R ) range;
}
Or, well, something like it. I
On 09/01/2010 11:49 PM, Peter Alexander wrote:
On 1/09/10 9:08 PM, Philippe Sigaud wrote:
Peter, can we discuss your solution here?
Sure, I'd be interested to hear any improvements. Like I said in my
answer, I'm still learning D so I'm sure there's many issues. For
example, I made no attempt
On 2/09/10 7:34 AM, Pelle wrote:
It needs opEquals :-)
Yeah, it needs a lot of things :)
You could easily add unary operators as well (e.g. so that -amb([1, 2])
== [-1, -2]. I didn't bother adding more than I did because it would
make the post too large, and wouldn't really add anything (I
On Thu, Sep 2, 2010 at 09:06, Peter Alexander
peter.alexander...@gmail.comwrote:
On 2/09/10 7:34 AM, Pelle wrote:
It needs opEquals :-)
Yeah, it needs a lot of things :)
You could easily add unary operators as well (e.g. so that -amb([1, 2]) ==
[-1, -2]. I didn't bother adding more than
Philippe Sigaud philippe.sig...@gmail.com wrote in message
news:mailman.42.1283371696.858.digitalmar...@puremagic.com...
Hey, this question on SO makes for a good challenge:
http://stackoverflow.com/questions/3608834/is-it-possible-to-generically-implement-the-amb-operator-in-d
The amb
Nick Sabalausky a...@a.a wrote in message
news:i5p68t$2pt...@digitalmars.com...
Philippe Sigaud philippe.sig...@gmail.com wrote in message
news:mailman.42.1283371696.858.digitalmar...@puremagic.com...
Hey, this question on SO makes for a good challenge:
Hey, this question on SO makes for a good challenge:
http://stackoverflow.com/questions/3608834/is-it-possible-to-generically-implement-the-amb-operator-in-d
The amb operator does this:
amb([1, 2]) * amb([3, 4, 5]) == amb([3, 4, 5, 6, 8, 10])
amb([hello, world]) ~ amb([qwerty]) ==
On 1/09/10 9:08 PM, Philippe Sigaud wrote:
Peter, can we discuss your solution here?
Sure, I'd be interested to hear any improvements. Like I said in my
answer, I'm still learning D so I'm sure there's many issues. For
example, I made no attempt for const-correctness or anything like that
41 matches
Mail list logo