|
Re: Max / Min Operation? [message #640116 is a reply to message #640087] |
Fri, 19 November 2010 07:47 |
|
This is a multi-part message in MIME format.
--------------080504080304090703000907
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi,
I believe that "iterate" is the closest you'll find. If "myMeasure" is
your collection of numbers :
myMeasure->iterate(current; result : Integer = myMeasure->first() |
result.min(current))
There may be better ways, but this is what I thought of first :p
Laurent Goubet
Obeo
On 19/11/2010 03:03, Miles Parker wrote:
> I'm wondering if anyone has thought about a good approach to finding the
> element with minimum or maximum value of a given expression from within
> a collection? The only way I can think of is to do a sort():
>
> myMeasure.sortBy(e | e.value).last().value;
>
> .but of course that is doing way more work than necessary. All we need
> to be able to do is traverse the whole list once. But there isn't anyway
> to communicate state between evaluations of collection operators.
> Perhaps someone has a more clever way of handling this? I thought about
> doing something lispish like dividing tails and heads and doing the
> compare that way but that can lead to lispish size stacks as well..
--------------080504080304090703000907
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------080504080304090703000907--
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04297 seconds