Post Reply 
Finding minimum in list
03-22-2017, 05:29 PM
Post: #6
RE: Finding minimum in list
(03-22-2017 03:30 PM)Han Wrote:  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?

In my particular application it so happens that I do want the first occurrence if there are the multiple elements with the same first value. I haven't specifically tried this approach, but I have used loop constructs that did pretty much the same thing. Thank you for your idea!

Thanks Didier! I think your approach is exactly what I was hoping for. I did not use the SORT command, but now that I see it in action, I should have! I don't think it gets any more efficient than that to accomplish my objective.

-Dale-
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: 1 Guest(s)