Command needed for striping brackets
|
02-20-2021, 10:47 PM
Post: #1
|
|||
|
|||
Command needed for striping brackets
in HOME:
CAS.convert({48},"DOM_FLOAT")) CAS.convert([48],"DOM_FLOAT")) in cas: convert({48},DOM_FLOAT)) convert([48],DOM_FLOAT)) Eventually I found this way striping off brackets. Turning it into a function makes it a bit easier writing. Am still surprised, why not a dedicated command to do this. It seems an odd behavior to me, why, when using the SUB command on a numerical value clamped in list - or vector - brackets, leaves it the same (not stripping these brackets). The above commands shows, as alwise does with the Prime, keeping track of the difficulties with programing caused by the division - HOME / CAS. What are this separation really for, other than stress humans. Does anyone here know and explain this to me. I wish HP soon realizes and install a full blown HP48 (HP50G) language on this Prime calculator. A full one, even, so we can delete the Primes if so desired. essen |
|||
02-21-2021, 03:47 AM
Post: #2
|
|||
|
|||
RE: Command needed for striping brackets
Hi, I too was amazed by the absence of a command dedicated to the elimination of parentheses and so I built it:
#cas GET(r,u):= BEGIN RETURN r(u); END; #end For example: GET({8},1) gives 8 GET([8],1) gives 8 GET({8,2,6,4,7},3) gives 6 |
|||
02-21-2021, 05:00 AM
Post: #3
|
|||
|
|||
RE: Command needed for striping brackets
I don't understand the reason for such a complicated method of extracting an element. Why not just do something like:
Code: r:=[2.5, 2, 0.8]; I just tested this on the virtual calculator build 2.1.13325 (2020 1 16) Graph 3D | QPI | SolveSys |
|||
02-21-2021, 07:28 AM
Post: #4
|
|||
|
|||
RE: Command needed for striping brackets
(02-21-2021 05:00 AM)Han Wrote: I don't understand the reason for such a complicated method of extracting an element. Why not just do something like:-------------------- This just stores the whole vector - take a look at your calculators memory. It does not extract and store the element 2.5 Mine calculator software has just been upgraded to version 2.1.14425 (2020 01 16) I read your help post above. I find it very useful. So being surprised of this one answer from you. It could be different on your calculator. - But don't think it is. |
|||
02-21-2021, 08:11 AM
Post: #5
|
|||
|
|||
RE: Command needed for striping brackets
(02-21-2021 03:47 AM)robmio Wrote: Hi, I too was amazed by the absence of a command dedicated to the elimination of parentheses and so I built it: ---------------------------------- This doesn't work on my Prime. No matter how using Get/or get in Home or Cas, this command is inactive. My software has just been upgrade to 2.1.14425 (2020 01 16). Likewise this command was also inactive on the calculators former software. I invite others to confirm here what their Prime does and don't in regard to striping parenthesis from numerical. The newest "Prime G" could be corrected. I think it unwise trying install Prime G software on my older not a "G model hardware". essen |
|||
02-21-2021, 03:51 PM
Post: #6
|
|||
|
|||
RE: Command needed for striping brackets
Well, here is a screen capture:
Can you provide a screen capture of yours? In your screen capture, include the following commands: Code:
Graph 3D | QPI | SolveSys |
|||
02-21-2021, 11:10 PM
Post: #7
|
|||
|
|||
RE: Command needed for striping brackets
(02-21-2021 03:51 PM)Han Wrote: Well, here is a screen capture:-------------------------- I don't see your posted example have anything to do with the case I posted about. My post clearly display the need of a command to strip the brackets from a numerical enclosed in brackets. Your example do not use a command to strip these brackets. Instead it uses a store operation that stores a list (or vector list) that can have one or more elements in it. If looking in the memory, the list (or vector list) are stored as a list (or vector list) - as you did write it in the Primes command line. Afterwards you can call by indexing every single element from this stored list, and so it is striped - and that's what you do in your example. Yea, storing and calling the element that way, it will land on the Primes screen striped without the brackets. Again, what you did here are calling by indexing a list element from a stored list of elements. This will strip the brackets. I knew this method in forward. But it had nothing to do with my post concerning the need of a dedicated command to strip a single bracket enclosed element from its brackets. Your example method and my post are to be used in different programing situations. There's no equality between these 2 methods. By the way, referred to my other posted problem concerning storing individual enlisted numerical values in enlisted variables, both of same size, so that each variable are stored with its value separated from list format, has now become possible without running a loop, after upgrading my Prime software a few days ago. My Prime can now resemble the HP48 - 50 method of storing variables value.: {myv1,myv2, myv3}:={1,2,3} And the problem in this thread also was solved by own help. To me, below function is not what you wrote in your former thread - "complicated". It is as simple as can be. And it works, with both {}, [] : #cas STRIP(ele):= BEGIN LOCAL e1; e1:=ele; e1:=convert(e1,DOM_FLOAT); RETURN(e1); END; #end |
|||
02-21-2021, 11:57 PM
(This post was last modified: 02-22-2021 03:10 AM by Han.)
Post: #8
|
|||
|
|||
RE: Command needed for striping brackets
(02-21-2021 11:10 PM)essen Wrote: I don't see your posted example have anything to do with the As you can see, it doesn't matter if it's a vector, or a single-element vector (or an object surrounded by []'s or {}'s as you put it). Quote:Your example do not use a command to strip these brackets. Because it does not seem necessary. That is why I mentioned that it seemed strange to implement a "stripping" program when simply using the functional notation is sufficient to extract the object inside the vector/list. While your goal is to also store the extracted value, my post was merely to point out that there is a simpler method of "stripping". Your replies keep focusing on the fact that I store a vector into 'r' -- yes, this is true that I store a vector into 'r'. But that is not what the point of my example was; the point was to show you that once you have a list (which I created and named 'r' as an example), you can use the functional notation r(i) to extract the i-th element. Quote:Instead it uses a store operation that stores a list (or vector list) that can The method I describe, and which you claim you already knew, works for any sized list/vector, including ones that have only a single element. So why the need for a conversion program? Quote:Your example method and my post are to be used in different programing situations. There's no equality between these 2 methods. It is quite possible that I am not understanding your larger goals in your program. Quote:By the way, referred to my other posted problem concerning storing Yes, this works if you have an explicit list. It was not clear to me whether your lists were referenced or not. As an example, if you have two lists named l1:={var1, var2, var3} and l2:={1,2,3}, using l1:=l2 will replace l1 with the l2 so that both l1 and l2 contain the list {1,2,3}. But it will not store 1 into var1, 2 into var2, and 3 into var3. On the other hand, explicitly using {var1, var2, var3}:={1,2,3} will store 1 into var1, 2 into var2, and 3 into var3. Quote:And the problem in this thread also was solved by own help. To me, You can simplify this with: Code:
or even: Code: #cas It is not necessary to create the local variable e1 that just duplicates the local variable ele. While the convert command does operate on the content of the variable, it uses a copy. Even the last program might not even be needed if you have your 1-element objects stored as a variable, because you could simply use the r(1) notation while replacing r with whatever variable you chose in your program to store the 1-element object. I get the feeling that perhaps you are taking offense to my posts due to possible language differences. I'll go ahead and make this post my last one for this topic. Graph 3D | QPI | SolveSys |
|||
02-22-2021, 12:02 AM
(This post was last modified: 02-22-2021 12:07 AM by Didier Lachieze.)
Post: #9
|
|||
|
|||
RE: Command needed for striping brackets
Btw, head({8}) returns 8 and head([9]) returns 9
(02-20-2021 10:47 PM)essen Wrote: It seems an odd behavior to me, why, when using the SUB command on a numerical value clamped in list - or vector - brackets, leaves it the same (not stripping these brackets). Regarding SUB, it extracts a subset of a list or of a matrix/vector. As such and to be consistent it returns a list or a matrix/vector even if there is only one element. |
|||
02-22-2021, 08:09 AM
(This post was last modified: 02-22-2021 08:16 AM by essen.)
Post: #10
|
|||
|
|||
RE: Command needed for striping brackets
(02-22-2021 12:02 AM)Didier Lachieze Wrote: Btw, head({8}) returns 8 and head([9]) returns 9--------------------------- The "head command" works. I knew this from use in HP48. It slipped my mind trying it in Prime. Thank you for this post. |
|||
02-22-2021, 08:34 AM
Post: #11
|
|||
|
|||
RE: Command needed for striping brackets
(02-21-2021 11:57 PM)Han Wrote: [quote='essen' pid='143252' dateline='1613949052'] As you can see, it doesn't matter if it's a vector, or a single-element vector (or an object surrounded by []'s or {}'s as you put it). Quote:Your example do not use a command to strip these brackets. Because it does not seem necessary. That is why I mentioned that it seemed strange to implement a "stripping" program when simply using the functional notation is sufficient to extract the object inside the vector/list. While your goal is to also store the extracted value, my post was merely to point out that there is a simpler method of "stripping". Your replies keep focusing on the fact that I store a vector into 'r' -- yes, this is true that I store a vector into 'r'. But that is not what the point of my example was; the point was to show you that once you have a list (which I created and named 'r' as an example), you can use the functional notation r(i) to extract the i-th element. Quote:Instead it uses a store operation that stores a list (or vector list) that can The method I describe, and which you claim you already knew, works for any sized list/vector, including ones that have only a single element. So why the need for a conversion program? Quote:Your example method and my post are to be used in different programing situations. There's no equality between these 2 methods. It is quite possible that I am not understanding your larger goals in your program. Quote:By the way, referred to my other posted problem concerning storing Yes, this works if you have an explicit list. It was not clear to me whether your lists were referenced or not. As an example, if you have two lists named l1:={var1, var2, var3} and l2:={1,2,3}, using l1:=l2 will replace l1 with the l2 so that both l1 and l2 contain the list {1,2,3}. But it will not store 1 into var1, 2 into var2, and 3 into var3. On the other hand, explicitly using {var1, var2, var3}:={1,2,3} will store 1 into var1, 2 into var2, and 3 into var3. Quote:And the problem in this thread also was solved by own help. To me, You can simplify this with: Code:
or even: Code: #cas It is not necessary to create the local variable e1 that just duplicates the local variable ele. While the convert command does operate on the content of the variable, it uses a copy. Even the last program might not even be needed if you have your 1-element objects stored as a variable, because you could simply use the r(1) notation while replacing r with whatever variable you chose in your program to store the 1-element object. I get the feeling that perhaps you are taking offense to my posts due to possible language differences. I'll go ahead and make this post my last one for this topic. [/quote] --------------------------- [ As an example, if you have two lists named l1:={var1, var2, var3} and l2:={1,2,3}, using l1:=l2 will replace l1 with the l2 so that both l1 and l2 contain the list {1,2,3}. But it will not store 1 into var1, 2 into var2, and 3 into var3. On the other hand, explicitly using {var1, var2, var3}:={1,2,3} will store 1 into var1, 2 into var2, and 3 into var3. ] -------------------------------- I did show you the explicit - {myv1,myv2, myv3}:={1,2,3} Having bracketed numerical standing in the Prime window it requires one to do 3 operations with your method. 1. for storing it 2. another one for calling it 3. another one to delete the stored list from the memory. After a while using your method, if not deleted, the memory would be full of unwanted lists. [ I get the feeling that perhaps you are taking offense to my posts due to possible language differences. I'll go ahead and make this post my last one for this topic. ] It's okay. I rather wants to be free of falling down and trapped in a kind of well, sitting there, while somebody come running offering me a packed of lunch. I wants have my foods on the ground. And be escaped Albert's accusing people here for indirection - a behavior used by himself. It is not an advantage for neither the bettering of the Primes usability and its sales. Now after 7 years with the Prime on market, the HP concern should realize it's not a good idea having "Hanger-on" in a forum, pressing button and hurting other participants with accusations used by them self. The other answers here understood my question and answered with relevant responses to it. But as said earlier to one of them , the "GET command" are inactive. The head command works. So a stripping command was there. It slipped my mind using it in Prime. I'm leaving this forum. You're right, its not a question of differences or lack in native English or American languages. |
|||
02-22-2021, 08:58 AM
Post: #12
|
|||
|
|||
RE: Command needed for striping brackets
(02-22-2021 08:34 AM)essen Wrote: I'm leaving this forum... That deprived you of a chance to learn something. Especially from Han and Didier, who know a lot about HP Prime and are always very willing to share their knowledge. Prime G2, 15C CE |
|||
02-23-2021, 05:47 PM
Post: #13
|
|||
|
|||
RE: Command needed for striping brackets
(02-22-2021 08:34 AM)essen Wrote: And be escaped Albert's accusing people here for indirection - a behavior used by himself. I am going against what I wrote earlier and making one last post. It is indeed an issue of language. The word indirection in the context of programming refers to how variables are accessed (directly vs. indirectly). Instead, you chose to take offense from this word without understanding its programming meaning. The irony is that you conclude that language was not an issue. That said, this is definitely my last post on this thread. Graph 3D | QPI | SolveSys |
|||
02-24-2021, 10:08 AM
Post: #14
|
|||
|
|||
RE: Command needed for striping brackets
(02-23-2021 05:47 PM)Han Wrote:---------------------------------------------(02-22-2021 08:34 AM)essen Wrote: And be escaped Albert's accusing people here for indirection - a behavior used by himself. For Han and Albert.: Sorry, my bad ! Well; I looked it up in a dictionary as not knowing the word, and could not afterwards se any other meaning as used in Alberts text. In my dictionary it stands like this: indirection [indi'recSen] sb uaerlighed, svigfuldhed, kneb, fif. These four words stands for; dishonesty, deceitfulness, trick, dodge. This created a meaning - a wrong one - unfortunately. This dictionary are dated 1977. Could be the reason. Or this English word just means other in us. My excuse doesn't mean that I' m fishing for yours and Alberts forgiveness. I am not. It just means I want to be honest telling how this did happen. By the way - concerning the answer to my Prime problem; This is all there are too it: {48}[1] Doing this in the command line places 48 on the stack without brackets. Coming from HP48, this simple instruction was not just apparent to me. Old far on this forum could be expected to know it and posted this answer. I tried to delete my account, as earlier said, I' m out from here. I am ready to start translating HP48 programs to Prime. Kind regards essen |
|||
02-24-2021, 12:52 PM
Post: #15
|
|||
|
|||
RE: Command needed for striping brackets
(02-24-2021 10:08 AM)essen Wrote: Well; I looked it up in a dictionary as not knowing the word, and I never used the word indirection. (this is my first post here) I looked up Eric Raymond's Jargon File, and the word is common enough that it is not even defined. I can see why you were offended. It is just a language misunderstanding. Here, we talk geek (in the good way) Here is another computer word which may be offensive: git - distributed version control system Quote:Git is a term of insult with origins in English denoting Quote:By the way - concerning the answer to my Prime problem; If it were this simple, the thread would not be this long. In HOME mode, HP Prime incorrectly parse it as variables, with implied multiply. HOME> {48}[1] → {48}*[1] → {[48]} Perhaps this is a bug ? |
|||
02-25-2021, 03:32 PM
Post: #16
|
|||
|
|||
RE: Command needed for striping brackets
(02-24-2021 12:52 PM)Albert Chan Wrote:---------------------------------(02-24-2021 10:08 AM)essen Wrote: Well; I looked it up in a dictionary as not knowing the word, and I found the same limit with STRIP({48},DOM_FLOAT), posted earlier here by me, when running it in PRIME emulator, it only works in calculator cas input mode. The reason are, that it's not the DOM_FLOAT that is doing the stripping. The stripping of the brackets from the enclosed numerical is done alone by storing and calling the enclosed argument. The only way without storing and calling it, are noted by, Didier ,using the head command, head({48}). So I would still prefer a dedicated stripping command. Fine, you accept a mistake. |
|||
03-01-2021, 07:00 AM
(This post was last modified: 03-02-2021 08:15 PM by essen.)
Post: #17
|
|||
|
|||
RE: Command needed for striping brackets
(02-25-2021 03:32 PM)essen Wrote:(02-24-2021 12:52 PM)Albert Chan Wrote: I never used the word indirection. (this is my first post here)--------------------------------- Addition: The list-Sum function will strip the brackets. It works both for {} and []. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)