(49G) (49g+) (50g) (48gII) NMDUP
|
05-16-2018, 06:12 PM
(This post was last modified: 11-11-2018 12:58 PM by DavidM.)
Post: #1
|
|||
|
|||
(49G) (49g+) (50g) (48gII) NMDUP
DUPN and NDUPN are very useful RPL commands that also happen to be very fast ways of replicating objects on the stack. DUPN makes a single copy of the number of objects specified:
1 2 3 3 DUPN => 1 2 3 1 2 3 ...and NDUPN makes a single object with the specified number of copies, followed by the number of copies: 7 8 9 3 NDUPN => 7 8 9 9 9 3. Another similar scenario that can be useful has no single command, though. Specifically, replicating a group of objects a set number of times. The following SysRPL program can be used to perform this function: Code: :: Compile the above and give it a suitable name (I use NMDUP). To use it, place two numbers on the stack which represent the following: 2: N (the number of elements in the stack to replicate/group size) 1: M (the number copies of the elements to make) Note that M represents the total quantity of duplicates, not the additional ones. So a quantity of 0 is the same as dropping N elements, a quantity of 1 does nothing, etc. Likewise, an N of 0 will have no affect on the rest of the stack, as there are no stack items identified for replication. Examples: 1 2 3 3 0 NMDUP => <nothing> 1 2 3 3 1 NMDUP => 1 2 3 1 2 3 3 2 NMDUP => 1 2 3 1 2 3 1 2 3 2 5 NMDUP => 1 2 3 2 3 2 3 2 3 2 3 1 2 3 0 5 NMDUP => 1 2 3 |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(49G) (49g+) (50g) (48gII) NMDUP - DavidM - 05-16-2018 06:12 PM
RE: (49G 49g+ 50g 48gII) NMDUP - John Keith - 08-11-2018, 04:11 PM
RE: (49G 49g+ 50g 48gII) NMDUP - DavidM - 08-11-2018, 04:22 PM
|
User(s) browsing this thread: 1 Guest(s)