DIM in a program - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: DIM in a program (/thread-1020.html) |
DIM in a program - Angus - 04-02-2014 09:24 AM imagine this piece of code: Code:
Is it really not possible to assign something like DIM(vector)(1) to a local in one step? I tried in cas and that works. I switched home from rpn to textbook and found that calling DIM(vec)(1) is translated to DIM(vec)*(1) there which seems to be a side effect of automatic operator expansion. However in a program such behaviour is painful, you just would not expect your code to be modified by the system. RE: DIM in a program - eried - 04-02-2014 09:47 AM Why are you using the return of dim as a list? dim returns the length of the string RE: DIM in a program - Angus - 04-02-2014 10:03 AM Maybe that is another capitalized non-capitalzed matter? In fact I expected the length to be a number and not a list containing the length. I found that I got a list.... But I did use DIM in the program. A few seconds ago I tried both dim() and DIM() in the cas. vec:=[1,2,3,4,5]; invocing dim(vec) in the cas turns to DIM(vec) in the history und results in 5. invocing DIM(vec) in the cas gives {5}. That is strange P.S. The original question on splitting up a command to part1*part2 remains, though. For a student learning to program that can really become a problem don't you think? RE: DIM in a program - eried - 04-02-2014 10:09 AM Strange, I get 1 with dim and lowercase dim gets uppercased. Well, yeah I don't like a lot the * thing either, seems counter intuitive but there should be a reason because otherwise why the calculator ask "create ___ variable?" instead of just creating it, it might be related to something internal. I think the double quotes handling (try to use a string function in the cas and modify something later, without undo/redo is even more frustrating) in the cas is much more annoying than the * thing. RE: DIM in a program - Angus - 04-02-2014 10:46 AM I forgot to mention that I used the simulator. There dim() is also converted to uppercase and the result is as expected. But using uppercase DIM() from the beginning gives you a list containing the result. Have to validate that with the calculator later the day. edit: I checked it in the calculator doing DIM(vec) in the cas causes an "Unmatch control word" error. So the beaviour is different than in my simulator. But I still get a list from dim used in a program. Could someone please confirm that? RE: DIM in a program - eried - 04-02-2014 11:48 AM The lower/upper case explain at least the issue in the code, this works: Code: LOCAL dim2:=EXPR("dim("+vec+")(1)"); The CAS/Program DIM just returns 1 number, not a list. RE: DIM in a program - Angus - 04-02-2014 12:12 PM That is astounding: I just keep getting a list or an Error (from inside a program in cas itself things are fine). Starts getting frustrating. Thank you anyhow - maybe we get some more comments here and my fault is solved. |