[Prev][Next][Index][Thread]

Re: count



In article <20010305163954.23103.qmail@web2103.mail.yahoo.com>, Gabor 
Greif <gabor68@yahoo.com> wrote:

> There is still some problem with the argument order
> passed to test, but I guess the above is sensible as
> most comparisons don't care (symmetric) and the it
> would work with
> 	count(seq, <integer>, test: instance?)
> just as \select does.

If the argument order is wrong for the test, you can always pass in a 
custom method that ignores the argument and uses a closure variable 
instead.

Or, for that matter, one that swaps the argument order e.g.

  count(seq, #f, test: method(a,b) instance?(b,<integer>) end);

OR

  count(seq, <integer>, test: method(a,b) instance?(b,a) end)


I think the determining factor is to make things such as...

  count(seq, 3, \<)

... work as expected.  Whichever meaning that is :-)   I vote for "3 < 
elt", which is the same as curry(\<, 3).


The other alternative is to be like "choose" and pass in only a 
predicate function, but I think the case of testing for equality to a 
value is common enough to want to make that easy.

-- Bruce



References: