Post Reply 
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
case I posted about. My post clearly display the need of a command
to strip the brackets from a numerical enclosed in brackets.

   

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
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.

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
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}

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,
below function is not what you wrote in your former thread - "complicated".
It is as simple as can be. And it works, with both {}, [] :

[quote]#cas
STRIP(ele):=
BEGIN
LOCAL e1;
e1:=ele;
e1:=convert(e1,DOM_FLOAT);
RETURN(e1);
END;
#end

You can simplify this with:
Code:

#cas
STRIP(ele):=
BEGIN
return(convert(ele,DOM_FLOAT));
END;
#end

or even:
Code:
#cas
STRIP(ele):=
return(ele(1));
END;
#end

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
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Command needed for striping brackets - Han - 02-21-2021 11:57 PM



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