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: Kaitzschu <kaitzschu@kaitzschu.cjb.net.nospam.plz.invalid>
Date: Mon Oct 31 2005 - 20:19:30 CET

On Mon, 31 Oct 2005, Bryan Oakley wrote:

> Kaitzschu wrote:
>> On Mon, 31 Oct 2005, Donal K. Fellows wrote:
>>
>>> As far as I can tell, it does the right thing on the two sample cases
>>> you've posted so far.
>>>
>>> % flatten [list \{ \}]
>>> { }
>>> % flatten [list [list a b] c [list d e [list f g]]]
>>> a b c d e f g
>>
>>
>> And fails this (unposted case),
>> % flatten [list "fgoo bar" "boooo far"]
>> fgoo bar boooo far
>> which, I guess, is pretty much impossible to avoid, since lists don't force
>> single whitespace.
>>
>
> You have a list with two elements, and each element is a list of two
> elements. The result of the flatten should be a list of four elements,
> right? You get four elements, so what's the problem?

But I don't have sublists, I have only one list, with two elements, both
being arbitrary strings. The fact that latter has multiple whitespace is
not preservable. In case those are mandatory, flattening just can't be
done without knowing nesting depth.

-- 
-Kaitzschu
s="TCL ";while true;do echo -en "\r$s";s=${s:1:${#s}}${s:0:1};sleep .1;done
Received on Mon Nov 21 00:37:26 2005