List Commands Library for 50g
|
06-25-2017, 04:52 PM
Post: #6
|
|||
|
|||
RE: List Commands Library for 50g
(06-24-2017 10:11 AM)pier4r Wrote: Nice! More list processing to do then! (...but [it] is big enough to keep one busy) I've started looking at some of your other requests... #1 - "listHeadIterate" -- your description was: Quote:...it is all for iterations instead of using DOLIST The more I looked at that, the more I realized that the basic pieces for doing this are already in place, and in fact it can be done fairly easily (and quickly) with a few simple commands. So rather than making a separate command for this, I'd suggest using the following instead: Code: listHeadIterate The comments make that look longer than it really is. I believe it does what you are looking for, and its performance should be about as good as a dedicated function would be. #2 - A new "POS"-like function to return a list of all matching objects. I like this idea, and I believe I've got a working version of what you have in mind. As I am not very imaginative with names, I'm suggesting it simply be called "LPOS" to denote that the results are in list form. It will be in the next release. #3 - "listContains" (list of elements in L2 present in L1). If I am not mistaken, that is exactly what the GoferList "Intersect" command does, and it handles duplicates in the same way that you mentioned in your request. I'm not keen to reinvent GoferList commands unless there is something wrong with them or substantial performance improvements are possible. I don't see either of those in this case. #4 - "given a list made of sublists, return the sublist positions that contain a given element" Still thinking about this one. It doesn't seem like it would be difficult to do, but this feels like a problem that can be generalized a bit further. For example, if I think of this as some sort of "membership" function, I could see returning a list of truth elements (0 or 1) that denote if the given argument is a member of the corresponding list element, which could be either a sublist or another object. Something like this: { { 1 2 3 } { 3 4 5 } 1 2 3 } 3 LMEMB (or some better command name ) output: { 1 1 0 0 1 } You would then have to do further processing to get the list of positions, but with the new LPOS command that could be done quite easily: 1 LPOS output: { 1 2 5 } What do you think? |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)