On Tue, 2012-07-24 at 13:56 -0400, Andrei Alexandrescu wrote: […] > The example is: > > int[] arr1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; > auto s = take(arr1, 5); > assert(s.length == 5); > assert(s[4] == 5); > assert(equal(s, [ 1, 2, 3, 4, 5 ][])); > > Were you referring to this? Example code does not need to be generic, > and in this case it's fine if the code relies on random access because > it uses an array of integers.
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. -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: rus...@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
signature.asc
Description: This is a digitally signed message part