Re: Handling pathological lists
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: Handling pathological lists

From: Earl Grieda <eASQWERTgrieda@VADFWEFyahoo.comical>
Date: Fri Oct 28 2005 - 20:19:55 CEST

"Bruce Hartweg" <bruce-news@hartweg.us> wrote in message
news:Xdr8f.4$F41.1@dfw-service2.ext.ray.com...
>
>
> keithv wrote:
>
> > Boiling down a complex problem to a simple problem,
> > I need to find the llength of the first item of a
> > list. Simple right? Just:
> >
> > llength [lindex $myList 0]
> >
> > But this fails if you have a pathological list such as:
> >
> > set myList [list \{ \}]
> >
> > => llength [lindex $myList]
> > unmatched open brace in list
> >
> > Granted this is a contrived example, but is there
> > a way of handling this without resorting to catch?
> >
>
> don't use list commands on things that aren't lists.
>

Isn't the purpose of the "list" command to create a proper list?

"This command returns a list comprised of all the args,..."
http://www.tcl.tk/man/tcl8.4/TclCmd/list.htm

Or, should the poster have used "split";
set myList [split "\{ \}"]

"Returns a list created by splitting string at each character that is in the
splitChars argument"
http://www.tcl.tk/man/tcl8.4/TclCmd/split.htm
Received on Mon Nov 21 00:36:47 2005