Post Reply 
RPL mini-challenge: Create an anti-Identity Matrix
05-13-2018, 09:51 AM (This post was last modified: 05-13-2018 10:13 AM by pier4r.)
Post: #19
RE: RPL mini-challenge: Create an anti-Identity Matrix
Playing around, not yet done. The problem is the construction. The matrix routines are blazing fast but then editing them is a pain (subtraction for example). So better to construct them right directly.

Still fixed values (adapting with variables shouldn't be that hard but will cost some additional time).
Edit: oh this idea is very similar to the one from Claudio already.
Code:

@1.04 seconds
\<< -1. 28.
  FOR iter 1. 29. NDUPN iter - 0. SWAP ROLLD 30. \->LIST
  NEXT 30. \->LIST AXL
\>>

The code from claudio (post http://www.hpmuseum.org/forum/thread-107...l#pid97587) here is pretty fast. It is like mine, only he is better, he is creating all the 900 elements on the stack (I create 30 elements each time) and then using the array command to compact them in a matrix. Neat. I did not know!
The part that I never like is that without comments one has to debug the code to understand what the code is doing. And that shouldn't happen.
Code:

@0.32 seconds
\<< 0. 29.
  FOR K 
  1. 29. NDUPN 1. + K - 0. SWAP ROLLD
  NEXT 
  29. 1. + 
  DUP 2. \->LIST 
  \->ARRY
\>>


Code:

@6.5 seconds
@ replacing { with [ in string operations.
@ so AXL is not that bad
\<< -1. 28.
  FOR iter 
    1. 29. NDUPN iter - 0. SWAP ROLLD 
    30. \->LIST
  NEXT 
  30. \->LIST 
  \->STR 
  "{" "[" SREPL DROP 
  "}" "]" SREPL DROP 
  OBJ\->
\>>
Question: in user RPL how do I replace a charachter in a specific position? Like I have "12345" I want to replace 4 with 8 to get "12385". I was thinking PUT would do the job, but the AUR says no.

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 09:51 AM



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