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: Darren New <dnew@san.rr.com>
Date: Mon Oct 31 2005 - 02:26:20 CET

keithv wrote:
> But let me restate the problem: write a routine that
> flattens a list, e.g.

The problem here is, again, that the requirements are underspecified.
What exactly do you mean by "flatten a list"? After all,
    a {b c {d e} f} g
is already a flat string. It's not like it's LISP we're talking about.

Once you express it in a way that makes sense in Tcl, the implementation
becomes obvious. For example, you might mean "Attempt to interpret the
input as a list with sublists, and repeatedly remove inner levels of the
list until the input can no longer be interpreted as a list or the
input's elements can no longer be interpreted as lists" or some such.

Basically, "flatten a list" doesn't make sense if the input cannot be
interpreted as a list, so if you don't specify what to do in that case,
you've specified only half the problem. And you're complaining that it
doesn't work for the unspecified cases.

-- 
   Darren New / San Diego, CA, USA (PST)
    Neither rocks nor slush nor salted rims
    shall keep us from our appointed rounds.
Received on Mon Nov 21 00:37:19 2005