You're right. I didn't read over the OP's example carefully
enough. The
mutation is being done to a module-level variable in an inout
function, which
is completely legit. I thought that what the OP thought was
wrong was mutating
a module-level variable in a non-mutable function (and that's
perf
On Wednesday, 26 June 2013 at 20:51:35 UTC, Gary Willoughby wrote:
Just for a bit of fun, I saw this question posted on reddit the
other day and wondered how *you* would solve this in D?
http://stackoverflow.com/questions/731832/interview-question-ffn-n
Well, considering there is little to th
On Thursday, June 27, 2013 03:31:01 anonymous wrote:
> On Thursday, 27 June 2013 at 00:53:48 UTC, Jonathan M Davis wrote:
> > It looks to me like your code is fundamentally different from
> > the OP's example
> > rather than being a simplification of the original code. In the
> > OP's example,
> >
On Thursday, 27 June 2013 at 00:53:48 UTC, Jonathan M Davis wrote:
It looks to me like your code is fundamentally different from
the OP's example
rather than being a simplification of the original code. In the
OP's example,
the variable being mutated is a module-level variable, so the
immutabil
On Thursday, June 27, 2013 01:45:22 anonymous wrote:
> On Wednesday, 26 June 2013 at 15:48:42 UTC, Jonathan M Davis
>
> wrote:
> > It doesn't break anything. It just shows the need for pure.
>
> Really? In the following simplified code I see mutation of an
> immutable variable, which should not b
On 6/27/13, Andrej Mitrovic wrote:
> On 6/27/13, H. S. Teoh wrote:
>> Well, it's still cheating, though. :-P I think the 4-cycle algorithm is
>> probably still the best one I've seen.
>
> What I don't understand is why the CPU is so slow that it takes ages
> to go through int.min .. int.max in a
On Wednesday, 26 June 2013 at 22:43:05 UTC, David wrote:
Am 26.06.2013 22:51, schrieb Gary Willoughby:
I solved it ;)
http://dpaste.dzfl.pl/5cd56e9d
Yes, but "maybe" the interviewer is waiting just one function,
since the question was: "Design a function f". So I rewrote your
example:
impo
On 6/27/13, H. S. Teoh wrote:
> Well, it's still cheating, though. :-P I think the 4-cycle algorithm is
> probably still the best one I've seen.
What I don't understand is why the CPU is so slow that it takes ages
to go through int.min .. int.max in a loop.
On Wednesday, 26 June 2013 at 15:48:42 UTC, Jonathan M Davis
wrote:
It doesn't break anything. It just shows the need for pure.
Really? In the following simplified code I see mutation of an
immutable variable, which should not be possible, of course. That
is breaking the type system, no? What
On Thu, Jun 27, 2013 at 12:43:04AM +0200, David wrote:
> Am 26.06.2013 22:51, schrieb Gary Willoughby:
> > Just for a bit of fun, I saw this question posted on reddit the other
> > day and wondered how *you* would solve this in D?
> >
> > http://stackoverflow.com/questions/731832/interview-questio
On Wednesday, 26 June 2013 at 22:43:05 UTC, David wrote:
Am 26.06.2013 22:51, schrieb Gary Willoughby:
Just for a bit of fun, I saw this question posted on reddit
the other
day and wondered how *you* would solve this in D?
http://stackoverflow.com/questions/731832/interview-question-ffn-n
I
On 6/26/13, Gary Willoughby wrote:
> Just for a bit of fun, I saw this question posted on reddit the
> other day and wondered how *you* would solve this in D?
>
> http://stackoverflow.com/questions/731832/interview-question-ffn-n
Silly mathematicians, nobody said you had to make it performant.
i
Am 26.06.2013 22:51, schrieb Gary Willoughby:
> Just for a bit of fun, I saw this question posted on reddit the other
> day and wondered how *you* would solve this in D?
>
> http://stackoverflow.com/questions/731832/interview-question-ffn-n
I solved it ;)
http://dpaste.dzfl.pl/5cd56e9d
> Anyway I've yet to see a solution that works for all input ;)
Scratch that.
--
Marco
Am Wed, 26 Jun 2013 22:52:17 +0200
schrieb "Gary Willoughby" :
> The text from the question:
>
> Design a function f, such that:
>
> f(f(n)) == -n
> Where n is a 32 bit signed integer; you can't use complex numbers
> arithmetic.
>
> If you can't design such a function for the whole range of
> n
On Wednesday, 26 June 2013 at 20:51:35 UTC, Gary Willoughby wrote:
Just for a bit of fun, I saw this question posted on reddit the
other day and wondered how *you* would solve this in D?
http://stackoverflow.com/questions/731832/interview-question-ffn-n
First answer port:
http://dpaste.dzfl.p
On Wednesday, 26 June 2013 at 20:51:35 UTC, Gary Willoughby wrote:
Just for a bit of fun, I saw this question posted on reddit the
other day and wondered how *you* would solve this in D?
Since they didn't say *pure* function, I'd cheat:
int f(int n) {
static bool isOddCall;
isOddCall = !is
The text from the question:
Design a function f, such that:
f(f(n)) == -n
Where n is a 32 bit signed integer; you can't use complex numbers
arithmetic.
If you can't design such a function for the whole range of
numbers, design it for the largest range possible.
Just for a bit of fun, I saw this question posted on reddit the
other day and wondered how *you* would solve this in D?
http://stackoverflow.com/questions/731832/interview-question-ffn-n
On Wednesday, 26 June 2013 at 15:48:42 UTC, Jonathan M Davis
wrote:
It doesn't break anything. It just shows the need for pure.
- Jonathan M Davis
OO I just got it :(
nevermind then...
On Wednesday, June 26, 2013 13:16:16 monarch_dodra wrote:
> It seems safe, however, your example seems to show how to indeed
> break the type system... without a cast (!):
>
> @property
> Point* ptr() inout {
> points[this.id].x = cast(int) this.x;
> points[this.id].y =
On Wednesday, 26 June 2013 at 13:45:41 UTC, lx wrote:
On Wednesday, 26 June 2013 at 04:46:32 UTC, Ali Çehreli wrote:
On 06/25/2013 09:26 PM, lx wrote:
> Ctrl+z seems close the stream.So,if I want
> to input another batch of data,it became impossilbe.So,how to
reopen the
> stream again to allow
On Wednesday, 26 June 2013 at 04:46:32 UTC, Ali Çehreli wrote:
On 06/25/2013 09:26 PM, lx wrote:
> Ctrl+z seems close the stream.So,if I want
> to input another batch of data,it became impossilbe.So,how to
reopen the
> stream again to allow me to input another batch of data?
Making a copy of st
On Wednesday, 26 June 2013 at 07:35:08 UTC, Namespace wrote:
On Tuesday, 25 June 2013 at 23:39:45 UTC, Ali Çehreli wrote:
With apologies, I have unrelated comments to make.
On 06/25/2013 03:07 PM, Namespace wrote:
> this(T x, T y) {
> this.x = x;
> this.y = y;
>
> p
On Wednesday, 26 June 2013 at 07:55:29 UTC, Namespace wrote:
Today Mike Parker figured out that it happens only if
scope(exit) is used in combination with glPopAttrib. But
That's not exactly what I was getting at. The problem isn't with
scope(exit) or, I believe, glPopAttrib. It just so happen
Second workaround so far:
Use something like that:
scope(exit) glAvoidAE(glPopAttrib(mask));
with
void glAvoidAE(lazy void Func) {
Func();
}
That's strange.
Since I had a problem by using derelict3 (more precise: I get an
Access Violation), Mike Parker and I were looking for the
problem. Today Mike Parker figured out that it happens only if
scope(exit) is used in combination with glPopAttrib. But because
we have not much experience in reading assem
On Tuesday, 25 June 2013 at 23:39:45 UTC, Ali Çehreli wrote:
With apologies, I have unrelated comments to make.
On 06/25/2013 03:07 PM, Namespace wrote:
> this(T x, T y) {
> this.x = x;
> this.y = y;
>
> points ~= &this._point;
I have seen similar designs in the
28 matches
Mail list logo