title: Improve proc to calculate the depth of a list using tcl 8.6. features
body: <p>I found a wiki page about how to calculate the depth of a list:
   <a href="http://wiki.tcl.tk/11602" rel="nofollow">http://wiki.tcl.tk/11602</a></p>
  
  <p>How can I rewrite the above code as a <strong>single proc</strong> using tcl 8.6 features <strong>lmap</strong> and <strong>apply</strong>? Perhaps "apply" is not really needed.</p>
  
  <pre><code>proc max list {
      set res [lindex $list 0]
      foreach e [lrange $list 1 end] {if {$e&gt;$res} {set res $e}}
      set res
  }
  
  # llmap perhaps can be replaced with lmap from Tcl 8.6
  proc llmap {func list} {
      set res {}
      foreach e $list {lappend res [$func $e]}
      set res
   }
  
  proc ldepth list {
      expr {
          [llength $list] == 0? 1:
          [expr {[lindex $list 0] eq $list}]?       0:
             1+[max [llmap ldepth $list]]
      }
   }
  </code></pre>