Post Reply 
New RPL: New Commands
01-21-2017, 08:17 PM (This post was last modified: 01-21-2017 11:03 PM by The Shadow.)
Post: #15
RE: New RPL: New Commands
I've been pondering some more on list commands, and I think I've come up with a really useful one: LFREQ.

It takes a list L and returns two: A list of the unique elements in L, and a list of how many times each shows up in L.

Now LFREQ DROP will give the "eliminate duplicates" command I suggested earlier. Plus, of course, it has wider applicability.

Perhaps the reverse of LFREQ would also be useful: Take lists of elements and their frequencies and build a list. Call it LBUILD, maybe?

So say you want no element to appear more than twice. You just do LFREQ << IF DUP 2 > THEN DROP 2 END >> MAP LBUILD

Plus, if there's a particular element you want to eliminate, you just insert a 0 as its frequency.

EDIT: Using LFREQ on the columns of (sigma)DAT would also be useful. Doing LFREQ DUP << MAX >> STREAM POS GET would give you the mode, for example. (Though you'd have to get a little more complicated to deal with ties.)

EDIT: LBUILD could interpret negative frequencies as "Do INV if it makes sense for the object, then insert ABS(frequency) times." Useful when dealing with factors of rational numbers.

EDIT: LFREQ and LBUILD should play nicely with a new version of FACTORS, too, since the exponents are just the frequencies of the list of prime factors.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
New RPL: New Commands - compsystems - 12-28-2016, 06:06 PM
RE: New RPL: New Commands - Vtile - 12-28-2016, 06:15 PM
RE: New RPL: New Commands - compsystems - 12-28-2016, 08:17 PM
RE: New RPL: New Commands - Claudio L. - 12-29-2016, 03:16 AM
RE: New RPL: New Commands - compsystems - 01-16-2017, 12:17 AM
RE: New RPL: New Commands - Claudio L. - 01-16-2017, 04:24 PM
RE: New RPL: New Commands - compsystems - 01-16-2017, 04:39 PM
RE: New RPL: New Commands - Claudio L. - 01-17-2017, 02:26 PM
RE: New RPL: New Commands - Vtile - 01-17-2017, 03:50 PM
RE: New RPL: New Commands - Claudio L. - 01-17-2017, 07:42 PM
RE: New RPL: New Commands - The Shadow - 01-19-2017, 07:06 AM
RE: New RPL: New Commands - The Shadow - 01-20-2017, 07:42 PM
RE: New RPL: New Commands - Claudio L. - 01-20-2017, 11:47 PM
RE: New RPL: New Commands - The Shadow - 01-21-2017, 04:29 AM
RE: New RPL: New Commands - Claudio L. - 01-22-2017, 01:53 AM
RE: New RPL: New Commands - The Shadow - 01-22-2017, 04:10 AM
RE: New RPL: New Commands - The Shadow - 01-21-2017 08:17 PM



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