Command needed for striping brackets
|
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 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)