List Commands Library for 50g
|
10-01-2017, 12:56 PM
(This post was last modified: 10-01-2017 01:26 PM by pier4r.)
Post: #182
|
|||
|
|||
RE: List Commands Library for 50g
After a quick look in listExt and goferlist I did not find it, so request (maybe I already requested it, I don't remember).
What about such a command (for list of integers/reals or even just reals): L3: input list L2: list positions to increment L1: increments to apply (same size of the position lists) example L3: { 0 0 1 0 2 } L2: { 1 2 5 } L1: { 3 2 1 } --- L1: { 3 2 1 0 3 } Or is it too better to use the built in ADD ? Like: L2: { 0 0 1 0 2 } L1: { 3 2 0 0 1 } (maybe a bit cumbersome to create?) ADD Of course, given the increment, one then would request for subtractions as well (and in the best case multiplication, division). This let me think that maybe the built in operations are already good, since they are already there. Also random pick from a list. One could do: (short, but maybe not always quick with large lists) {list} LSHUF HEAD or (way longer but pinpointing) {list} DUP SIZE RAND * 1 + IP GET What about something like: {list} LRPICK (List random pick) Pick a random element from the list. Returns: L2: position of the element L1: value {list} n LRPICKM (List random pick multiple) Pick randomly 'n' times from the list (so the list can be even smaller than n). Produces in output 2 lists L2: {positions} L1: {values} {list} n LRPICKMU (List random pick multiple unique) Pick randomly 'n' times from the list without picking from the same position, so n should be at most the size of the list. Produces in output 2 lists L2: {positions} L1: {values} This one can be approximated with: {list} LSHUF n LFRST Approximated because one has no positions. <Spoiled>I want more high quality commands like the others in listExt that simplify programs and avoid that I write my own little libraries. </spoiled> (at the end it is my fault, I could have collected various short and fast programs already while reading the forum. Actually I should do it, to provide myself and others with a valid library for lazy people like me) Wikis are great, Contribute :) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)