Project

General

Profile

Feature #771

New fns: MaxBy and MinBy to find minimum/maximum of a list wrt a given order

Added by John Abbott over 8 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
CoCoA-5 function: new
Target version:
Start date:
05 Sep 2015
Due date:
% Done:

100%

Estimated time:
Spent time:

Description

CoCoA offers SortBy for a sorting a list wrt a given order. Anders would like a fn to find the min/max of a list wrt a given order.

History

#1 Updated by John Abbott over 8 years ago

Do we want these fns?

I already have (simple) implementations in my own personal copy of list.cpkg5.

If we want them then someone must also write documentation.

#2 Updated by Anna Maria Bigatti over 8 years ago

  • % Done changed from 0 to 20

John Abbott wrote:

Do we want these fns?
I already have (simple) implementations in my own personal copy of list.cpkg5.

Yes!

If we want them then someone must also write documentation.

I can do it (after you check them in)

#3 Updated by John Abbott over 8 years ago

  • Status changed from New to In Progress
  • % Done changed from 20 to 50

JAA has checked that the fns work on a simplish example.

Code checked in.

Anna say's she'll write doc. And a test?

>>> l:=["abc","def","g","hijk","lm"];

>>> MaxBy(l,shorter);
hijk

>>> MinBy(l,shorter);
g

#4 Updated by Anna Maria Bigatti over 8 years ago

There is only one detail I'm undecided about:
you implemented the function with argument LessThan whereas it came natural to me to implement it as GreaterThan. I'm now investigating how else we use this kind of idea.

#5 Updated by John Abbott over 8 years ago

I wanted to be compatible with SortBy and SortedBy, and perhaps also the C++ STL...

#6 Updated by Anna Maria Bigatti over 8 years ago

John Abbott wrote:

I wanted to be compatible with SortBy and SortedBy, and perhaps also the C++ STL...

OK, I was confused... we always used LessThan. Maybe I should improve the manual ;-)

#7 Updated by Anna Maria Bigatti over 8 years ago

Tested and documented (and improved manual for SortedBy)

#8 Updated by Anna Maria Bigatti over 8 years ago

  • Status changed from In Progress to Feedback
  • Assignee set to John Abbott
  • % Done changed from 50 to 90

#9 Updated by John Abbott about 8 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100

Closing after 5 months in feedback.

Also available in: Atom PDF