Post Reply 
Finding minimum in list
03-22-2017, 03:30 PM
Post: #2
RE: Finding minimum in list
(03-22-2017 03:14 PM)DrD Wrote:  I'm looking for ideas to efficiently locate the second value, of the minimum value of all first values, within a list of paired lists. For example, I would like set var R=2, from the minimum of all first values, {1,2 }, in this example list:

L0:={{5,1},{1,2},{1.25,3},{1.167,5}};
R:=2; // from item in red's second value

-Dale-

I don't suppose you have already tried something like:

Code:
EXPORT MINFIRST()
BEGIN
  L1:=MAKELIST(L0(J,1),J,1,SIZE(L0));
  M:=MIN(L1);
  M:=POS(L1,M);
  RETURN(L0(M,2)); // R:=L0(M,2);
END;

In the event of two or more sublists having the same minimal first values, the first occurrence will be used. Did you have any other conditions for such cases?

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Finding minimum in list - DrD - 03-22-2017, 03:14 PM
RE: Finding minimum in list - Han - 03-22-2017 03:30 PM
RE: Finding minimum in list - DrD - 03-22-2017, 05:29 PM
RE: Finding minimum in list - Han - 03-22-2017, 05:42 PM
RE: Finding minimum in list - Tyann - 03-23-2017, 05:38 AM
RE: Finding minimum in list - DrD - 03-25-2017, 02:25 PM
RE: Finding minimum in list - Han - 03-25-2017, 03:10 PM
RE: Finding minimum in list - Han - 03-22-2017, 04:11 PM
RE: Finding minimum in list - Han - 03-22-2017, 04:32 PM
RE: Finding minimum in list - DrD - 03-23-2017, 10:18 AM
RE: Finding minimum in list - John P - 03-26-2017, 04:11 AM
RE: Finding minimum in list - DrD - 03-28-2017, 01:52 PM
RE: Finding minimum in list - DrD - 03-29-2017, 10:54 AM



User(s) browsing this thread: 2 Guest(s)