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: Donald Arseneau <asnd@triumf.ca>
Date: Sun Oct 30 2005 - 19:56:35 CET

"keithv" <kvetter@gmail.com> writes:

> But let me restate the problem: write a routine that
> flattens a list, e.g.
> where: [list [list a b] c [list d e [list f g]]]
> becomes: {a b c d e}

{a b c d e f g}?

proc flatten { lis } {
  set len -1
  while { $len != [set len [llength $lis]] } {
    set lis [eval concat $lis]
  }
  return $lis
}

-- 
Donald Arseneau                          asnd@triumf.ca
Received on Mon Nov 21 00:37:16 2005