List Commands Library for 50g
|
09-29-2017, 09:39 PM
Post: #177
|
|||
|
|||
RE: List Commands Library for 50g
(09-29-2017 07:19 PM)pier4r Wrote: 2b. Thanks for voting. You're the expert on how many votes are needed for this to be statistically meaningful! (09-29-2017 07:19 PM)pier4r Wrote: ...in particular: The built-in SORT command already does this. It's the basis for how KSORT works -- it simply combines the two lists into this form, executes SORT (or your given program), then unbundles the combined lists back into their original (but now sorted) groups. Sorting two lists by the values would be done simply by swapping the value and key lists before executing KSORT. (09-29-2017 07:19 PM)pier4r Wrote: A command that returns if a key exists (and how many times)? Wouldn't it be easier to simply keep the keys and values in their own lists? That way you achieve the above with { key or value list } <target> LCNT/MPOS/etc. If you need to perform operations on the combined value/key lists in the above format, simply pass your program as the third argument to KSORT. Yes, I know the name is KSORT, but the supplied user program doesn't actually have to sort the list. See the command description for details. KSORT doesn't really care what the supplied program does, it just has to leave a list in the proper format on the stack when it's done so that the list can be unbundled properly. Give it some thought. I think you'll find that keeping the keys and values as separate lists has some nice benefits, and KSORT provides some nice flexibility by allowing you to execute a user-supplied program on the bundled list. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 18 Guest(s)