Finding minimum in list
03-26-2017, 04:11 AM (This post was last modified: 03-26-2017 04:15 AM by John P.)
Post: #12
 John P Member Posts: 216 Joined: Dec 2013
RE: Finding minimum in list
My two cents to the discission. It works in CAS and HOME on the latest emulator.

EXPORT COLEXTR(l,c,fl)
//l: array, c: col you consider
//fl: flag, fl=0 for min, fl=any other
//integer for max.
BEGIN
local tc=mat2list(col(l,c));
if fl==0
then return(l(pos(tc,min(tc))));
else return(l(pos(tc,max(tc))));
end;
END;

If you also need position you can create local var. ex. tp, and change the lines in the then and else blocks to: tp:=pos(tc,min(tc)); tp:=pos(tc,max(tc)); and put return(l(tp),tp); outside of the if construct.
 « Next Oldest | Next Newest »

 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 - Didier Lachieze - 03-22-2017, 04:06 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 - cyrille de brĂ©bisson - 03-28-2017, 10:30 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 RE: Finding minimum in list - Didier Lachieze - 03-29-2017, 06:50 PM

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