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. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)