On 30-8-2013 0:40, H. S. Teoh wrote:
(...)
A far better implementation is to use std.range.recurrence:
uint fib(in uint n) pure nothrow {
return recurrence!((a,n) => a[n-2] + a[n-1])(1, 1)
.drop(n-1)
.front;
}
This
On 08/29/2013 08:53 PM, Meta wrote:
> However, after some fiddling, it seems that this is actually not
usable with
> anonymous functions, or at least, I couldn't find a way to do it.
Borrowing the "self" trick from the existing solution, the following
satisfies all of the requirements:
int
On Thursday, 29 August 2013 at 22:01:38 UTC, H. S. Teoh wrote:
That's clever, but I'm not sure I understand the bit about
anonymous functions? You don't need anonymous functions to have
recursion.
Sorry, that came out all wrong. What I meant was that it's neat
to be able to do anonymous recur
On 08/29/2013 04:37 PM, bearophile wrote:
> H. S. Teoh:
>
>> Also, this is a pretty poor algorithm for generating the Fibonacci
>> series,
>
> I know, but you must do what the tasks asks you:
>
> http://rosettacode.org/wiki/Anonymous_recursion
>
> Bye,
> bearophile
Hm... Like some of the other l
On Fri, Aug 30, 2013 at 01:37:39AM +0200, bearophile wrote:
> H. S. Teoh:
>
> >Also, this is a pretty poor algorithm for generating the Fibonacci
> >series,
>
> I know, but you must do what the tasks asks you:
>
> http://rosettacode.org/wiki/Anonymous_recursion
[...]
OK I see.
I wish we could
H. S. Teoh:
Also, this is a pretty poor algorithm for generating the
Fibonacci series,
I know, but you must do what the tasks asks you:
http://rosettacode.org/wiki/Anonymous_recursion
Bye,
bearophile
On Thu, Aug 29, 2013 at 03:00:09PM -0700, H. S. Teoh wrote:
> On Thu, Aug 29, 2013 at 11:00:49PM +0200, Robik wrote:
> > On Thursday, 29 August 2013 at 18:57:58 UTC, Meta wrote:
> > >uint fib(in uint n) pure nothrow {
> > >immutable self = &__traits(parent, {});
> > >return (n < 2) ? n : se
On Thu, Aug 29, 2013 at 11:00:49PM +0200, Robik wrote:
> On Thursday, 29 August 2013 at 18:57:58 UTC, Meta wrote:
> >uint fib(in uint n) pure nothrow {
> >immutable self = &__traits(parent, {});
> >return (n < 2) ? n : self(n - 1) + self(n - 2);
> >}
> >
> >I came across this while browsing
On Thursday, 29 August 2013 at 18:57:58 UTC, Meta wrote:
uint fib(in uint n) pure nothrow {
immutable self = &__traits(parent, {});
return (n < 2) ? n : self(n - 1) + self(n - 2);
}
I came across this while browsing Rosetta Code. It's really
cool how you can do recursion without anonymo
uint fib(in uint n) pure nothrow {
immutable self = &__traits(parent, {});
return (n < 2) ? n : self(n - 1) + self(n - 2);
}
I came across this while browsing Rosetta Code. It's really cool
how you can do recursion without anonymous functions (and this
will actually not work if you make
10 matches
Mail list logo