Post Reply 
RPL mini-challenge: Create an anti-Identity Matrix
05-13-2018, 07:32 PM
Post: #24
RE: RPL mini-challenge: Create an anti-Identity Matrix
(05-13-2018 03:01 PM)DavidM Wrote:  PUT doesn't work with strings, but REPL does:

"12345" 4 "8" REPL

yields

"12385"

If you simply want all instances of a given character replaced, use SREPL.

Thanks. I knew SREPL but I missed REPL. When will I finish to have an idea of all the commands (and inputs) of the RPL base library? (no additional libraries!) It is enormous. I guess counting a function for a type of input, so different types (and combinations of types) of inputs counts as different functions, the RPL base library is easily over 2000 functions. Many of which should still be investigated. For example how speedy they are. Impressive what HP has done (considering also the community support). I wonder if the prime has such extensive library as well. I did not dive deep there. Surely the casio 9860G is much more simpler with the casio basic. On the 9860G maybe other inteepreters or the SDK enable the user to close the gap with the 50g.

Already in this thread I learned more about \->ARRY and subtleties.

Anyway, the program modified to use variables. I did not test it extensively, but for the test done it works. Reals in input. Speed with input 30: 0.20 seconds.
Code:

  \<< 
    @ Idea: create N-1 rows of the form 0 1 1 .. 1 with as many 1 as N
    @ add an ending 0
    @ compact it in a matrix
    
    \->
    mDim
    
    \<<
      1. mDim 1 -
      START 
        0. 1. mDim NDUPN DROP
      NEXT 
      0. 
      
      mDim mDim 2. \->LIST \->ARRY
    \>>
  \>>

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?

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: RPL mini-challenge: Create an anti-Identity Matrix - pier4r - 05-13-2018 07:32 PM



User(s) browsing this thread: 1 Guest(s)