Take and website

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Jul 24 11:21:09 PDT 2012


On 7/24/12 2:17 PM, Russel Winder wrote:
> That's the one.
>
> s[4] relies on the fact that arr1 is an array:
>
>   ( takeExactly ( recurrence ! ( "a[n-1] + a[n-2]" ) ( 0L , 1L ) , cast
> ( size_t ) ( n + 1 ) ) ) [ n ]
>
> fails with operator [] not defined, I find I have to:
>
> array ( takeExactly ( recurrence ! ( "a[n-1] + a[n-2]" ) ( 0L , 1L ) ,
> cast ( size_t ) ( n + 1 ) ) ) [ n ]
>
> So the functions available on the results of a take depends on the data
> input. In one sense obvious, in another sense a total fubar since it is
> not necessarily clear what the types are in more complex situations.

I must have gotten a bit too used to it, but I think that's quite a 
basic reality imposed by the types involved... yes, that's as clear as 
xyz = 4.5 only works if xyz is of some certain types.

Anyhow, an example that shows how to print the nth Fibonacci number will 
be helpful. Could I impose on you to write a pull request?


Thanks,

Andrei




More information about the Digitalmars-d mailing list