Post Reply 
expanding list to objects
06-20-2016, 04:18 PM
Post: #10
RE: expanding list to objects
(06-19-2016 09:25 PM)Didier Lachieze Wrote:  @poznavatelj: I may be wrong but I don't think it's possible.

(06-19-2016 07:05 PM)Tonig00 Wrote:  by the way if somebody knows a command to eliminate repetitions in a list tell me {1,2,2,3} to give {1,2,3}

mat2list(CAS("{1,2,2,3} union {1,2,2,3}"))

I thought that would be a useful procedure - but I wasn't sure of the syntax needed to make {1,2,2,3} into a list parameter within a quoted string within CAS.

But here is a procedure to do that in PPL

Code:


 // StephenG1CMZ 2016

 LST_PurgedOfDuplicates(LST)
 //LST UNCHANGED. RETURN PURGED LST
 BEGIN
  LOCAL II;
  //LOCAL LST:={1,2,2,3};
  LOCAL OUTLST:={};

  //THIS SOLN-WORKS WHEREVER POS RECOGNISES ELE WITHIN LST
  FOR II FROM 1 TO SIZE(LST)  DO
   IF POS(OUTLST,LST(II)) THEN //DUPLICATE
   ELSE OUTLST(0):=LST(II); 
   END;
  END;
  //MSGBOX(OUTLST);
  RETURN OUTLST;
  //TO COUNT HOW MANY DUPLICATES PURGED: ON EXIT: SIZE(LST)-SIZE(RETURNVALUE); 
 END;

 EXPORT LISTER()
 BEGIN
  LOCAL UNIQUELST:=LST_PurgedOfDuplicates({1,2,2,3});
  RETURN UNIQUELST;
 END;

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
expanding list to objects - poznavatelj - 06-16-2016, 01:58 PM
RE: expanding list to objects - DrD - 06-16-2016, 02:16 PM
RE: expanding list to objects - retoa - 06-20-2016, 07:36 AM
RE: expanding list to objects - roadrunner - 06-20-2016, 11:08 AM
RE: expanding list to objects - Stevetuc - 06-21-2016, 10:10 AM
RE: expanding list to objects - Joe Horn - 06-21-2016, 09:12 AM
RE: expanding list to objects - Wes Loewer - 06-21-2016, 09:13 AM
RE: expanding list to objects - Tonig00 - 06-19-2016, 07:05 PM
RE: expanding list to objects - StephenG1CMZ - 06-20-2016 04:18 PM



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