RPL mini-challenge: Create an anti-Identity Matrix
|
05-14-2018, 07:12 PM
(This post was last modified: 05-14-2018 09:55 PM by DavidM.)
Post: #32
|
|||
|
|||
RE: RPL mini-challenge: Create an anti-Identity Matrix
(05-13-2018 07:32 PM)pier4r Wrote: Question: the code above, I believe, can get a further speed up if one could duplicate many objects on the stack at once. I do not know any command for this. Say I have 5 objects on the stack and I want to duplicate them, without using an explicit loop (surely the command internally will have a loop, like NDUPN). Is it possible? As 3298 has mentioned, NDUP will duplicate a group of stack objects. But it only makes one copy, so you would have to loop the calls to NDUP to replicate a group of objects multiple times. The SysRPL program listed below implements a command I've named "NMDUP", which does what I think you're referring to. It requires a 49g/49g+/50g/48gII, and its arguments are as follows: N+2: object 1 ... 3: object N 2: N (the count of discrete objects to replicate) 1: M (the number of duplicates of the above objects after replication) So to make 4 sets of 1, 2, and 3: 5: 1 4: 2 3: 3 2: 3 1: 4 NMDUP yields the following result 12: 1 11: 2 10: 3 9: 1 8: 2 7: 3 6: 1 5: 2 4: 3 3: 1 2: 2 1: 3 Code: :: (I've also attached the code object if you want to try it out) Using a SysRPL component is outside the scope of this challenge , but here's an example of how NMDUP might have been used: Code: \<< Edit: changed the error that is thrown if the stack doesn't have enough objects for NMDUP, and clarified the compatible platforms. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)