SWAPROW vs rowSwap in CAS

09302023, 08:04 PM
(This post was last modified: 10012023 06:41 PM by Lukas.)
Post: #1




SWAPROW vs rowSwap in CAS
Hello,
I've been playing around in CAS and ran into this: rowSwap([[1,2],[3,4]],1,2) → [[3,4],[1,2]] SWAPROW([[1,2],[3,4]],1,2) → [[3,4],[1,2]] Now let's introduce a variable rowSwap([[1,2],[3,x]],1,2) → [[3,x],[1,2]] So far so good, but then SWAPROW([[1,2],[3,x]],1,2) → "Error: Invalid input" I thought that rowSwap is just an alias of SWAPROW (or the other way around), but that doesn't seem to be the case. Is this expected behavior? Is SWAPROW supposed to give me this error message in this case? 

10012023, 04:38 AM
(This post was last modified: 10012023 04:47 AM by komame.)
Post: #2




RE: SWAPROW vs rowSwap in CAS
I didn't notice such a problem in CAS. Are you sure you're in CAS mode (there should be a "CAS" indicator in the upper left corner of the screen)? If you're in HOME mode, the variable 'x' is not treated as a symbol but as a numerical value. In this case, if 'x' doesn't have a numerical value assigned (meaning you're trying to substitute 'nothing' into a matrix field), it returns an error. A similar error will occur if 'x' is assigned a value that cannot be substituted into a matrix (e.g., a string).
When I did this in CAS mode, everything worked as expected. If you substitute a numerical value (e.g., 7) for 'x' in CAS mode, you will notice the difference in the behavior of these two functions. Piotr Kowalewski 

10012023, 06:41 PM
Post: #3




RE: SWAPROW vs rowSwap in CAS
I just tested it again and was not able to reproduce the problem.
When I ran into the issue yesterday I was in CAS mode too though. So I'm not sure what the problem was. Let's just hope that I don't run into it again. If I do I'll update this thread with more infos, but otherwise this issue can be considered to be resolved. Thank you for your input, Piotr! 

10022023, 05:55 AM
Post: #4




RE: SWAPROW vs rowSwap in CAS
rowSwap and SWAPROW share the same implementation, but the second one is indeed quoted, arguments are not evaled.


« Next Oldest  Next Newest »

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