Mark A. Biggar writes: > Austin Hastings wrote: > > > Gaal Yahas wrote: > > > > > list [==] 0, 0, 1, 2, 2; > > > # bool::false? > > > # (bool::true, bool::true, bool::false, bool::false, bool::false) > > > >(And I'm with Smylers on this one: show me a useful example, please.) > > Well the above example does tell you where the leading prefix of equal > values stops, assuming the second answer.
But you still have to iterate through the list of C<bools> to get that index -- so you may as well have just iterated through the input list and examined the values till you found one that differed. > Combined with reduce it gives some interesting results: > > [+] list [?&] @bits ==> index of first zero in bit vector Yer what? Are you seriously suggesting that as a sane way of finding the first element of C<@bits> that contains a zero? That doesn't even short-cut (since the addition reduction can't know that once it starts adding on zeros all the remaining values are also going to be zeros). > There are other APLish operators that could be very useful in > combination with reduce and scan: The fact that there are more operators that go with these only adds to my suspicion that this field of stuff is appropriate for a module, not the core language. > the bit vector form of grep (maybe called filter); > filter (1 0 0 1 0 1 1) (1 2 3 4 5 6 7 8) ==> (1 4 6 7) Please don't! The name 'filter' is far too useful to impose a meaning as specific as this on it. Smylers
