f

#### getting rid of '{}'

Hello,

I am using the 'list' data structure to build up a SIP INVITE message.
When I do that, the final message that is built has lotsa '{' braces in
it. How do I get rid of them?

A workaround could be to use 'lreplace', but it needs me to enter the
exact position/index value of the braces (which I can get using
lsearch).

I just wanted to know if there is a cleaner solution.

Best Regards,
Anuj Mistry.


 0
1/4/2006 12:59:12 PM
comp.lang.tcl 23429 articles. 2 followers.

9 Replies
586 Views

Similar Articles

[PageSpeed] 52

42 % string map {\{ "" \} ""} "{this is {an example {of nested
braces}}}"
this is an example of nested braces


 0
1/4/2006 1:40:56 PM
anuj wrote:
> Hello,
>
> I am using the 'list' data structure to build up a SIP INVITE message.
> When I do that, the final message that is built has lotsa '{' braces in
> it. How do I get rid of them?
>
> A workaround could be to use 'lreplace', but it needs me to enter the
> exact position/index value of the braces (which I can get using
> lsearch).
>
> I just wanted to know if there is a cleaner solution.

You need to provide us an example of what the data and what the commands you
are using to get these "unwanted braces".  Also provide us with what you
want to have at the end.

Unless a SIP INVITE message is a Tcl List, there is a good change you should
not be using list commands, but rather string commands to build up the message.

 0
Gerald.Lester (2014)
1/4/2006 1:42:00 PM
anuj wrote:
> Hello,
>
> I am using the 'list' data structure to build up a SIP INVITE message.
> When I do that, the final message that is built has lotsa '{' braces in
> it. How do I get rid of them?

Generally speaking, if you have a bunch of curly braces that are
magically appearing and you want to get rid of them, you're doing
something wrong. Either you're creating a list where you shouldn't be,
or using a list as a string without explicitly converting it to a string.

The question is, do you need to use a list structure in the first place?
If so, you need to explicitly convert the list to a string when you
finally create your SIP INVITE message. That can be as simple as [join
$list " "], or as complex as a loop that iterates over nested lists, piecing together your final string one word at a time. Of course, the other workaround is to do [string map [list \{ "" \} ""]$list], but that is exactly that -- a workaround. If you use Tcl's data
structures properly you should never have to manually remove curly braces.

 0
oakley (2075)
1/4/2006 2:04:42 PM
Hi Gerald,

Thanks.

The task at hand is to accept different parameters from the user (GUI)
and to assemble them to build the complete message. This message is
then sent out of a specified port.

I had a choice between using plain string and lists. I started off with
lists to build up the message. I declared an empty list and went on to
append (lappend) the different components of the message to the list.
So each component of the message is an item in the list. But when I
view the final (big) list, each individual component within the list is
enclosed within braces which I dont want.

Suchenwi,

The string map option seems to be good enough. Thanks.

The syntax says  -

string map ?-nocase? charMap string

If I use -

string map {\{ "" \} ""} $reqmsg it doesnt really knock ff the braces. It keeps the 'reqmsg' as it is. Is it because 'reqmsg' is a list and not a string? Thanks again. Regards, Anuj.   0 1/4/2006 2:25:18 PM anuj wrote: > Hi Gerald, > > Thanks. > > The task at hand is to accept different parameters from the user (GUI) > and to assemble them to build the complete message. This message is > then sent out of a specified port. > > I had a choice between using plain string and lists. I started off with > lists to build up the message. I declared an empty list and went on to > append (lappend) the different components of the message to the list. > So each component of the message is an item in the list. But when I > view the final (big) list, each individual component within the list is > enclosed within braces which I dont want. If that's the case, the solution is as simple as [join$list " "]. That
is, explicitly join every list element together with a space between them.


 0
oakley (2075)
1/4/2006 2:56:02 PM
>
> The string map option seems to be good enough. Thanks.
>
> The syntax says  -
>
> string map ?-nocase? charMap string
>
> If I use -
>
> string map {\{ "" \} ""} $reqmsg > > it doesnt really knock ff the braces. It keeps the 'reqmsg' as it is. > Is it because 'reqmsg' is a list and not a string? > How are you actually viewing the braces in the list? Does the server see these, or are you doing a [puts] with the list? If you print a list, what you see on the console is a string rep of that list, so it might not be necessarily true what you see. % set mylist [list "with a space" "" hello] {with a space} {} hello % puts [lindex$mylist 0]
with a space
% puts [lindex $mylist 1] % puts [lindex$mylist  2]
hello
% puts $mylist {with a space} {} hello %   0 1/4/2006 2:58:13 PM > I had a choice between using plain string and lists. I started off with > lists to build up the message. I declared an empty list and went on to > append (lappend) the different components of the message to the list. > So each component of the message is an item in the list. But when I > view the final (big) list, each individual component within the list is > enclosed within braces which I dont want. As Bryan wrote: join$reqmsg " "

append reqmsg " " $item > If I use - > > string map {\{ "" \} ""}$reqmsg
>
> it doesnt really knock ff the braces. It keeps the 'reqmsg' as it is.
> Is it because 'reqmsg' is a list and not a string?

string map takes a string not a variable to manipulate (that's why you
put $reqmsg not reqmsg). set reqmsg [string map {\{ "" \} ""}$reqmsg]

hth
Ronnie

 0
1/4/2006 3:15:24 PM
anuj wrote:
> If I use -
>
> string map {\{ "" \} ""} $reqmsg > > it doesnt really knock ff the braces. It keeps the 'reqmsg' as it is. > Is it because 'reqmsg' is a list and not a string? > Anuj, one thing you should understand. A lot of tcl's standard functions are purely functional, that is they don't modify their parameters but return the result instead (there are exceptions of course, like the incr command). So to use most of the advice given here you have to set a variable to the return value of the function: set reqmsg [string map {\{ "" \} ""}$reqmsg]

or for Bryan's solution:

set reqmsg [join $reqmsg " "] Seasoned tclers will often just mention the function and assume that you know how to 'set'.   0 slebetman (894) 1/4/2006 11:51:46 PM Thanks everyone for the help. Yes, I am a newbie, and I skipped the use of 'set'. Feels great to be able to access/talk to this TCL experts community!!!   0 1/5/2006 5:29:02 AM  Reply: Similar Artilces: 'is not' or '!=' A newbie question to you; what is the difference between statements like: if x is not None: and if x != None: Without any context, which one should be preferred? IMHO, the latter is more readable. On 2014-08-18 21:35, ElChino wrote: > A newbie question to you; what is the difference between statements > like: > if x is not None: > and > if x != None: > > Without any context, which one should be preferred? > IMHO, the latter is more readable. > "x == y" tells you whether x and y refer to objects that are equal. "x is y" tells you whether x and y actually refer to the same object. In the case of singletons like None (there's only one None object), it's better to use "is". "ElChino" <elchino@cnn.cn>: > A newbie question to you; what is the difference between statements > like: > if x is not None: > and > if x != None: Do the following: take two$10 bills. Hold one bill in the left hand, hold the other bill in the right hand. Now, the bill in the left hand "is not" the bill in the right hand. However, the bill in the left hand "==" the bill in the right hand. > Without any context, which one should be preferred? > IMHO, the latter is more readable. In almost all cases, both tests would result in the same behavior. However, the "is not" test is conceptually the correct one since you want...

'^=' and '~='?
Hello, What is the difference between '^=' and '~='? Thanks, Duckhye ...

to get my ''PLP''
I tried to install the MATLAB in my computer but idon't have my personal license password.i would like how to get my PLP? buy it Hi, http://www.mathworks.com/support/solutions/data/1-16LU2.html J�r�me ...

get(get(gca,'Children'),'xdata')
hi everybody i use get and gca to find the points of a plot by below m-file : syms x y B=0.3;d=1;m1=0.5;m2=1-m1; u=x-m1*x/(x^2+y^2)-m2*(x-B*m1*x/(x^2+y^2)-d)/((x-B*m1*x/(x^2+y^2)-d)^2+(y-B*m1*y/(x^2+y^2))^2); v=y-m1*y/(x^2+y^2)-m2*(y-B*m1*y/(x^2+y^2))/((x-B*m1*x/(x^2+y^2)-d)^2+(y-B*m1*y/(x^2+y^2))^2); k11=diff(u,x); k12=diff(u,y); k21=diff(v,x); k22=diff(v,y); det=k11*k22-k12*k21; subplot(2,1,1); ezplot(det,[-2,2],[-2,2]); t=get(get(gca,'Children'),'xdata') my problem is this for some value of B (for example B=2) it give the xdata of plot in form of array [1,n] .it is ok u...

How do I get rid of Mail's 'suggestions'
Actually, not me, my mother. She once typed my email address wrongly into Mail's 'To' field. Now, if she starts to type my address in that field (I'm trying to get her to use the address book instead), the programme brings up a list of everything she's ever typed there starting with the letter 'S', with the incorrect address at the top of the list. She forgets that this address is wrong, selects it, and wonders why her email bounces. Where are these 'suggestions' stored? Is there a preference I can disable or a file a can trash to get rid of them, or, at le...

How to get rid of '../..'
Hi, How can I get rid of '../..' in file name?.. For example, I need to get absolute file name from string '../../usr/bin/'. I find one solution with sed and I want to find maybe more elegant solution or just another way how I can make it. Sapfeer <Sapfeer@gmail.com> writes: >Hi, >How can I get rid of '../..' in file name?.. For example, I need to >get absolute file name from string '../../usr/bin/'. I find one >solution with sed and I want to find maybe more elegant solution or >just another way how I can make it. In POSIX shell synta...

'''''''''''''The Running Update/Append Queries Using VBA code Ordeal'''''''''''''' #2

if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.') Any shorter ?
Hi, there. =20 I'm just curious if it ever dawned on anybody how to abbreviate this line : if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.')=20 =20 Igor Kurbeko Clinical Programmer Analyst 678 336 4328 ikurbeko@atherogenics.com =20 no brain no pain =20 how about: if not (str_mo in ('','.') or str_da in ('','.') or str_yy in ('','.')) OR if not (missing(str_mo) or missing(str_da) or missing(str_yy)) Eric On 22 Oct 03 21:13:37 GMT, ikurbeko@ATHER...

How to browse all PropertyName for 'get' and 'set' function'?
hello all: Is there a way that I could browse all PropertyName for function 'get' and 'save'. For example: I want to know screen size then I use scrsz = get(0,'ScreenSize'); However, sometimes I don't know the correct propertyName(here is 'ScreenSize') for the function get or set. Thank you -Daniel Mark set(0) or h=handle(0); Then double click 'h' in workspace browser. Stuart "Daniel Mark" <danielmarkhot@Hotmail.com> wrote in message news:eee5db3.-1@webx.raydaftYaTP... > hello all: > > Is there a way that I could br...

A function with 'and' , 'not' , 'null' , 'car' and 'cdr'
What's this ? (defun enigma (x) (and (not (null x)) (or (null (car x)) (enigma (cdr x))))) "I suppose I should learn Lisp, but it seems so foreign." - Paul Graham, Nov 1983 On Wed, Oct 07 2015, CAI GENGYANG wrote: > What's this ? > > > (defun enigma (x) > (and (not (null x)) > (or (null (car x)) > (enigma (cdr x))))) Bad taste? It returns T if the list X contains nil as an element. It would be clearer to write (some #'null x). Helmut CAI GENGYANG ...

error: expected '=', ',', ';', 'asm' or '__attrib
Hi I'm trying to compile an ADC Driver & come acrosss the following error. I've no experience writing drivers before, and hence have no clue how to fix it. Hope someone out there has encountered the problem & suggesst a fix for the same. The Error is I get is : qadc.c: At top level: qadc.c:97: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'qadc_read' make: *** [qadc.o] Error 1 [root@localhost qadc]# ########################################################################### ADC Driver Code ##...

Replacing ',' with '.'
Hello, I have a huge amount of numbers in a .txt file. The numbers are in the form 2,43252e+1. I need to replace the , with . How should I do this? I'd prefer some import method that does this during the import procedure. -Janne Hi, I guess you import the data as text and convert it then to numbers. Try 'strrep' before you convert the text to numbers. Tobias Jake the Snake schrieb: > Hello, > > I have a huge amount of numbers in a .txt file. The numbers are in the form 2,43252e+1. I need to replace the , with . How should I do this? I'd prefer some import method...

'a'..'z'
Is it possible to achieve something like this? switch (mystring.charAt(0)) { case 'a'..'z': // do something break; } "cruster" <cruster@gmail.com> wrote in message news:1151319731.988814.326200@m73g2000cwd.googlegroups.com... > Is it possible to achieve something like this? > > switch (mystring.charAt(0)) { > case 'a'..'z': > // do something > break; > } > There are times when an if statement may be more appropriate ;) Sorry - java is not VB :) -- LTP :) cruster schreef: > Is it possible to achieve somethi...

Does '!=' equivelent to 'is not'
I'm a bit confusing about whether "is not" equivelent to "!=" if a != b: ... if a is not b: ... What's the difference between "is not" and "!=" or they are the same thing? pirata wrote: > I'm a bit confusing about whether "is not" equivelent to "!=" > > if a != b: > ... > > if a is not b: > ... > > > What's the difference between "is not" and "!=" or they are the same thing? No, they are not the same thing. == and != test to see if the *value* of two variables are the same. Like so: >>> a = 'hello world' >>> b = 'hello world' >>> a == b True a and b both have the value of 'hello world', so they are equal is and is not, however, do not test for value equivalence, they test for object identity. In other words, they test to see if the object the two variables reference are the same object in memory, like so: >>> a is b False a and b are assigned to two different objects that happen to have the same value, but nevertheless there are two separate 'hello world' objects in memory, and therefore you cannot say that a *is* b Now look at this: >>> c = d = 'hello world' >>> c == d True >>> c is d True In this case, they are again the same value, but now the is test also shows that they are the same *object* as well, because...

Override 'and' and 'or'
Is it possible to override 'and' and/or 'or'? I cannot find a special method for it... __and__ and __rand__ and __or__ and __ror__ are for binary manipulation... any proposals? Have marvelous sunday, Marco Dekker <m.aschwanden@gmail.com> wrote: > Is it possible to override 'and' and/or 'or'? I cannot find a special > method for it... __and__ and __rand__ and __or__ and __ror__ are for > binary manipulation... any proposals? If you want to customize the truth value testing you have to implement __nonzero__ " __nonzero__( self) Call...

'hi' i am the guy who hopes to 'get'
hi i am a puget sound 'front' welfare recipient i hope 'to get' so i bitch and moan and make a nuisance of myself i wish i could provide value but i can't so all i do is moan and whine On Sun, 27 Jul 2003 21:41:56 -0700, GreyCloud <cumulus@mist.com> wrote: >asso wrote: >> hi =20 >> i am a puget sound 'front' welfare recipient how sad. best to leave town, forever =20 >> i hope 'to get' ....there are Gift taxes =20 >> so i bitch and moan and make a nuisance of myself I'm not the only soul accused of hit-n-...

replacement for '{' and '}' ?
I am still playing around with what kind of syntax I would like to mark up my documents. Are there equivalent long substitutes for { and } when they are not used to describe arguments to functions? Something like \begin{group} and \end{group}. In other words, if I could force myself to write, say, \begin{group} \it ... \end{group} instead of {\it ... }, then I believe I could identify from the markup context what is an argument that belongs to a just invoked macro and what is text. {Of course, in this context, \textit{...} would be better.} No more ambiguity whether a in \myfunction{a} is an argument or just text. Is there a way to make latex barf when it sees an ordinary '{' in text, rather than \begin{group}, but not barf when I want it (to denote macro arguments)? Regards, /iaw On Aug 16, 6:01=A0pm, "ivo...@gmail.com" <ivo...@gmail.com> wrote: > Is there a way to make latex barf when it sees an ordinary '{' in > text, rather than \begin{group}, but not barf when I want it (to > denote macro arguments)? What do you mean exactly? I don't understand. Do you have in mind your- to-be-new-syntax or just regular latex? Cheers, Tomek ivowel@gmail.com wrote: > I am still playing around with what kind of syntax I would like to > mark up my documents. > > Are there equivalent long substitutes for { and } when they are not > used to describe arguments to functions? Something like \begin{group} > and \end{gr...

difference between ',' and 'a,'
Small question. In gforth is there a difference between the words ',' and 'a,'? I'm thinking not, so perhaps another question, why have both ',' and 'a,'? Thanks Should be the same, in gforth: see , : , here cell allot ! ; ok see a, : , here cell allot ! ; ok On Friday, January 9, 2015 at 5:46:04 AM UTC-8, beeflo wrote: > Small question. In gforth is there a difference between the words ',' and 'a,'? > > I'm thinking not, so perhaps another question, why have both ',' and 'a,'? > > Thanks beeflo <beeflobill@gmail.com> writes: >Small question. In gforth is there a difference between the words ',' and 'a,'? > >I'm thinking not, so perhaps another question, why have both ',' and 'a,'? In Gforth itself, there is no difference. In Gforth's cross compiler, "a," is there for addresses, and "," is there for other cells; addresses can then be relocated when loading the image. - anton -- M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html New standard: http://www.forth200x.org/forth200x.html EuroForth 2014: http://www.euroforth.org/ef14/ ...

'!' vs. '.'
Is there an advantage to using the '!' notation to represent form/ control relationships? (eg. Me!text1 vs Me.text1) I am currently using the '.' notation exclusively (for code completion in the VB Editor), but much of the high-quality code that I've seen (in Duane Hookom's Query-by-Form db, for example) uses the other. Here's one opinion for you: http://doc.advisor.com/doc/05352 robert.waters wrote: >Is there an advantage to using the '!' notation to represent form/ >control relationships? (eg. Me!text1 vs Me.text1) > >I am currently using the '.' notation exclusively (for code completion >in the VB Editor), but much of the high-quality code that I've seen >(in Duane Hookom's Query-by-Form db, for example) uses the other. -- HTH - RuralGuy (RG for short) acXP WinXP Pro Please post back to this forum so all may benefit. Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/200704/1 Here's my $0.02 worth on this. I tend to copy the notation style and naming conventions that I see being used in the Help files. That would be Me![text1] for a control on a form. I am of the belief that this notation explicitly refers to a control itself rather than a field in the form's recordset. Here's an example: I have a parts inventory app that uses a "Line" code, which is usually a 3-character abbreviation for a brand name, and is the na... logical to 'on' / 'off' Hi, is there a function implemented doing this conversion? my Problem is, that I want to use the following code: set(handles.edit_curr_trq_sl,'Enable',get(hObject,'Value')) where get(hObject,'Value') gives the state of a checkbox thank you! function [str]=tf2oo(logic) switch logic case 0 str='off'; case 1 str='on'; end%switch end%function tf2oo() while i do not know a built in function, I use my own:) meisterbartsch wrote: > > > function [str]=tf2oo(logic) > switch logic > case 0 > str='off'; &g... '[OFF]' as in 'offensive'??? Hi, given that 'off-topicness' is indicated as '[OT]' and taking a look at those postings that started the threads indicated as '[OFF]' (which may both be seen as being somewhat offensive) may lead to the conclusion that '[OFF]' stands for offensiveness. I don't think that this is the intended meaning so what actually *does* '[OFF]' mean? I never came across that abbreviation before (although I have been around on the USENET for quite some time) but maybe it is worth knowing? Josef 'Jupp' Schugt NOTE: mails >100 KiB ... Difference between 'is' and '==' Hey guys, this maybe a stupid question, but I can't seem to find the result anywhere online. When is the right time to use 'is' and when should we use '=='? Thanks alot~ mwql: >Hey guys, this maybe a stupid question, but I can't seem to find the >result anywhere online. When is the right time to use 'is' and when >should we use '=='? http://docs.python.org/ref/comparisons.html -- Ren� Pijlman mwql wrote: > Hey guys, this maybe a stupid question, but I can't seem to find the > result anywhere online. When is the right time to ... We Are Selling The Nextel I930 For Just$130usd'''''''''''
Dear Customer We have all brands of Mobile Phones,Ipods,Sidekicks,Nextel phone,Laptops for sell at cheap an affordable prices, they ranges from Nokia/Samsung/LG/Son Ericsson/Motorola/Alcatel/panasonic With Bluetooth, al Brands and Models of Nextel Phones, we want you to get bac to us with your quote so that we can begin a good busines relationship. Note they are all Brand New T2 Euro specs unlocked, no operator logo, come in thei original sealed box, With 1 year international warrant from the manufacturer, English & Spanish manual, Finlan made We want to assure you that you will never r...

Re: if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.') Any shorter ? #2
Igor, There are many ways to make it more concise, however the parsimony is likely to be achieved at the expense of clarity. For instance, the expressions length ( input (mm||dd||yy, \$10.) ) > 2 length ( compress(mm||dd||yy, ' .') ) > 2 and like might be somewhat shorter than the original, but they will execute slower, and their intent is far less eminent. Since it appears that you are trying to validate the components of a date, maybe it is not a worthless idea to try the date informat conforming to the mask you are testing. Say if all the pieces are 2-digit, the expression input (mm||dd||yy, ?? mmddyy6.) will return a missing value for the case you are testing and also if any irregularities in the input value that prevent it from being interpreted as a valid date should be found. And if you want a note in the log to alert you about it, leave one of the question marks off. Kind regards, ================= Paul M. Dorfman Jacksonville, FL ================= >From: Igor Kurbeko <ikurbeko@ATHEROGENICS.COM> >Reply-To: Igor Kurbeko <ikurbeko@ATHEROGENICS.COM> >To: SAS-L@LISTSERV.UGA.EDU >Subject: if str_mo not in ('','.') and str_da not in ('','.') and str_yy > not in ('','.') Any shorter ? >Date: Wed, 22 Oct 2003 17:13:37 -0400 > >Hi, there. > > > >I'm just curious if it ever dawned on anybody how to abbreviate this >line : > >if ...

Web resources about - getting rid of '{}' - comp.lang.tcl

Resources last updated: 3/13/2016 4:40:52 PM