Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/Counting+Elements+in+a+List?V=16
QUERY_STRINGV=16
CONTENT_TYPE
DOCUMENT_URI/revision/Counting+Elements+in+a+List
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.70.135.67
REMOTE_PORT26788
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip
HTTP_X_FORWARDED_FOR3.238.225.8
HTTP_CF_RAY737473043ab75878-IAD
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_USER_AGENTCCBot/2.0 (https://commoncrawl.org/faq/)
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_LANGUAGEen-US,en;q=0.5
HTTP_CF_CONNECTING_IP3.238.225.8
HTTP_CF_IPCOUNTRYUS
HTTP_CDN_LOOPcloudflare

Body


Error

Unknow state transition: LINE -> END

-code

1

-level

0

-errorstack

INNER {returnImm {Unknow state transition: LINE -> END} {}} CALL {my render_wikit {Counting Elements in a List} Is\ there\ a\ simple\ way\ to\ count\ the\ number\ of\ matching\ elements\ in\ a\ list?\ \ The\ answer\ is\ \"Yes.\ \ Several\ ways.\"\ \ \n----\n\nAnd\ just\ to\ keep\ things\ interesting,\ we\ can\ compare\ them\ in\ the\ context\ of\ a\ little\ test\ harness\ that\ times\ how\ quickly\ they\ run.\ \ There\ \nare\ many\ times\ when\ a\ Tcl\ programmer\ might\ want\ to\ compare\ a\ couple\ of\ndifferent\ techniques\ to\ see\ which\ is\ fastest.\ \ The\ '''time'''\ command\ncan\ often\ help.\ \ (See\ the\ \[Tcl\ Performance\]\ page\ for\ more\ information\non\ speed\ improvements.)\ \ --\ RWT\n\n\ \ \ \ #!/bin/sh\n\ \ \ \ #\ restart\ on\ the\ next\ line\ using\ tclsh\ \\\n\ \ \ \ exec\ tclsh\ \"\$0\"\ \"\[email protected]\"\n\n\ \ \ \ #----------------------------------------\n\ \ \ \ #\ \ Define\ procs\ to\ test\ each\ method\ for\n\ \ \ \ #\ \ counting\ identical\ list\ items.\ \ This\n\ \ \ \ #\ \ enables\ the\ byte-code\ compiler\ to\n\ \ \ \ #\ \ optimize\ the\ code.\n\ \ \ \ #----------------------------------------\n\ \ \ \ proc\ count_members1\ list\ \{\n\ \ \ \ \ \ \ \ foreach\ member\ \$list\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\[info\ exists\ count(\$member)\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ incr\ count(\$member)\n\ \ \ \ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ count(\$member)\ 1\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ \ \n\n\ \ \ \ proc\ count_members2\ list\ \{\n\ \ \ \ \ \ \ \ foreach\ x\ \$list\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\[catch\ \{incr\ count(\$x)\}\]\}\ \{set\ count(\$x)\ 1\}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ \ \n\n\ \ \ \ proc\ count_members3\ list\ \{\n\ \ \ \ \ \ \ \ foreach\ x\ \$list\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ expr\ \{\[catch\ \{incr\ count(\$x)\}\]\ &&\ \[set\ count(\$x)\ 1\]\}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ \ \n\n\ \ \ \ proc\ count_members4\ list\ \{\n\ \ \ \ \ \ \ \ foreach\ x\ \$list\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ lappend\ ulist(\$x)\ \{\}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ foreach\ name\ \[array\ names\ ulist\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ count(\$name)\ \[llength\ \$ulist(\$name)\]\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ \ \ \ \ \n\n\ \ \ \ proc\ count_members5\ list\ \{\n\ \ \ \ \ \ \ \ foreach\ x\ \$list\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ append\ ulist(\$x)\ .\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ foreach\ name\ \[array\ names\ ulist\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ count(\$name)\ \[string\ length\ \$ulist(\$name)\]\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ \ \ \ \ \n\n\ \ \ \ #----------------------------------------\n\ \ \ \ #\ \ Create\ some\ test\ data.\ \ In\ this\ case,\n\ \ \ \ #\ \ build\ a\ list\ of\ 10,000\ items\n\ \ \ \ #----------------------------------------\n\ \ \ \ set\ items\ \[list\ john\ paul\ jones\ mary\]\n\ \ \ \ for\ \{set\ i\ 0\}\ \{\$i<10000\}\ \{incr\ i\}\ \{\n\ \ \ \ \ \ \ \ lappend\ data\ \[lindex\ \$items\ \[expr\ \{int(rand()*\[llength\ \$items\])\}\]\]\n\ \ \ \ \}\ \ \ \n\n\n\ \ \ \ #----------------------------------------\n\ \ \ \ #\ \ Print\ some\ information\ about\ our\n\ \ \ \ #\ \ environment.\ \ This\ is\ very\ useful\n\ \ \ \ #\ \ when\ consulting\ comp.lang.tcl.\n\ \ \ \ #----------------------------------------\n\ \ \ \ puts\ \"\[info\ patchlevel\]\ over\ \$tcl_platform(os)\ \$tcl_platform(osVersion).\"\n\n\n\ \ \ \ #----------------------------------------\n\ \ \ \ #\ \ Run\ the\ tests.\n\ \ \ \ #\ \ Note\ that\ we\ have\ cleverly\ named\n\ \ \ \ #\ \ the\ test\ procs\ so\ that\ \[info\]\ can\n\ \ \ \ #\ \ easily\ find\ and\ execute\ them.\n\ \ \ \ #----------------------------------------\n\ \ \ \ foreach\ proc\ \[info\ proc\ count_members*\]\ \{\n\ \ \ \ \ \ \ \ puts\ \"\"\n\ \ \ \ \ \ \ \ puts\ \"\$proc\"\n\ \ \ \ \ \ \ \ puts\ \[time\ \{\$proc\ \$data\}\ 10\]\n\ \ \ \ \}\n\n----\n\[RS\]\ 2004-02-20:\ Note\ however\ that\ the\ above\ procs\ don't\ really\ yield\ their\ count\ -\ the\ local\ array\ is\ discarded\ on\ \[return\].\ For\ practical\ use,\ I\ modified\ ''count_members4''\ which\ was\ among\ the\ fastest\ in\ my\ tests\ on\ WinXP,\ to\ return\ a\ list\ of\ \{element\ count\}\ pairs:\n\ proc\ lcount\ list\ \{\n\ \ \ \ foreach\ x\ \$list\ \{lappend\ arr(\$x)\ \{\}\}\n\ \ \ \ set\ res\ \{\}\n\ \ \ \ foreach\ name\ \[array\ names\ arr\]\ \{\n\ \ \ \ \ \ \ lappend\ res\ \[list\ \$name\ \[llength\ \$arr(\$name)\]\]\n\ \ \ \ \}\n\ \ \ \ return\ \$res\n\ \}\n\ %\ lcount\ \{yes\ no\ no\ present\ yes\ yes\ no\ no\ yes\ present\ yes\ no\ no\ yes\ yes\}\n\ \{no\ 6\}\ \{yes\ 7\}\ \{present\ 2\}\n\nThe\ list\ is\ in\ hash\ (i.e.,\ apparently\ no)\ order,\ but\ you\ can\ post-process\ it\ to\n\ \ \ *\ alphabetic:\ lsort\ \[\[lcount\ \$list\]\]\n\ \ \ *\ numeric:\ lsort\ -integer\ -index\ 1\ -decr\ \[\[lcount\ \$list\]\]\n----\nI\ don't\ have\ 8.5\ at\ hand\ yet,\ but\ I\ expect\ this\ \[dict\]\ version\ to\ be\ a\ good\ solution\ too:\n\ proc\ lcount\ list\ \{\n\ \ \ \ set\ count\ \{\}\n\ \ \ \ foreach\ element\ \$list\ \{dict\ incr\ count\ \$element\}\n\ \ \ \ set\ count\n\ \}\n----\n\n\[gold\]\nHere's\ counting\ through\ a\ list\ of\ thrown\ dice\ combos\nfor\ probability.\ The\ worker\ bee\ is\nlsearch\ -all\ \$lister\ \$facen\ \ \n\$facen\ is\ the\ sum\ of\ a\ 2-dice\ throw\ like\ 7.\nSubroutine\ is\ invoked\ by\ a\ foreach\ procedure\ \nfor\ probability,\ which\ would\ be\ number\ of\ thrown\ 7's\nover\ all\ possible\ throws\ (\$lister).\ \nDrop\ (-all)\ and\ lose\ all,\nreturning\ only\ one\ position\ of\ \"7\"\ in\ list.\nSee\ Binomial\ Probability\ Slot\ Calculator\ Example,\nhttp://wiki.tcl.tk/26724.\n======\n\ \ \ \ \ console\ show\n\ \ \ \ \ proc\ calculation\ \{\ \ facen\ \}\ \ \{\ \n\ \ \ \ \ #\ prob.\ subroutines\ for\ two\ 6-sided\ dice\n\ \ \ \ \ set\ lister\ \{2\ 3\ 4\ 5\ 6\ 7\ 3\ 4\ 5\ 6\ 7\ 8\ 4\ 5\ 6\ \ /\n\ \ \ \ \ 7\ 8\ 9\ 5\ 6\ 7\ 8\ 9\ 10\ 6\ 7\ 8\ 9\ 10\ 11\ 7\ 8\ 9\ 10\ 11\ 12\}\n\ \ \ \ \ set\ ee\ \[llength\ \ \$lister\ \]\n\ \ \ \ \ set\ kk\ \[\ llength\ \[\ lsearch\ -all\ \$lister\ \$facen\ \]\ \]\n\ \ \ \ \ set\ prob\ \[\ expr\ \{\ (\$kk*1.)\ /\ \$ee\ \ \}\ \]\n\ \ \ \ \ return\ \$prob\n\ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ set\ limit\ 12\n\ \ \ \ \ \ \ \ \ \ for\ \{\ set\ i\ 1\ \}\ \{\ \$i\ <=\ \$limit\ \}\ \ \{\ incr\ i\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ lappend\ listxxx\ \$i\ \n\ \ \ \ \ \ \ \ \ \ lappend\ listxxx\ \[\ calculation\ \ \$i\ \]\n\ \ \ \ \ \ \ \ \ \ puts\ \"\ \$i\ \[\ calculation\ \ \$i\ \]\ \"\n\ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ #end\n=====\n\n----\nSee\ \[Chart\ of\ proposed\ list\ functionality\]\ too.\n----\n\[Category\ Command\] regexp2} CALL {my render {Counting Elements in a List} Is\ there\ a\ simple\ way\ to\ count\ the\ number\ of\ matching\ elements\ in\ a\ list?\ \ The\ answer\ is\ \"Yes.\ \ Several\ ways.\"\ \ \n----\n\nAnd\ just\ to\ keep\ things\ interesting,\ we\ can\ compare\ them\ in\ the\ context\ of\ a\ little\ test\ harness\ that\ times\ how\ quickly\ they\ run.\ \ There\ \nare\ many\ times\ when\ a\ Tcl\ programmer\ might\ want\ to\ compare\ a\ couple\ of\ndifferent\ techniques\ to\ see\ which\ is\ fastest.\ \ The\ '''time'''\ command\ncan\ often\ help.\ \ (See\ the\ \[Tcl\ Performance\]\ page\ for\ more\ information\non\ speed\ improvements.)\ \ --\ RWT\n\n\ \ \ \ #!/bin/sh\n\ \ \ \ #\ restart\ on\ the\ next\ line\ using\ tclsh\ \\\n\ \ \ \ exec\ tclsh\ \"\$0\"\ \"\[email protected]\"\n\n\ \ \ \ #----------------------------------------\n\ \ \ \ #\ \ Define\ procs\ to\ test\ each\ method\ for\n\ \ \ \ #\ \ counting\ identical\ list\ items.\ \ This\n\ \ \ \ #\ \ enables\ the\ byte-code\ compiler\ to\n\ \ \ \ #\ \ optimize\ the\ code.\n\ \ \ \ #----------------------------------------\n\ \ \ \ proc\ count_members1\ list\ \{\n\ \ \ \ \ \ \ \ foreach\ member\ \$list\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\[info\ exists\ count(\$member)\]\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ incr\ count(\$member)\n\ \ \ \ \ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ count(\$member)\ 1\n\ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ \ \n\n\ \ \ \ proc\ count_members2\ list\ \{\n\ \ \ \ \ \ \ \ foreach\ x\ \$list\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ if\ \{\[catch\ \{incr\ count(\$x)\}\]\}\ \{set\ count(\$x)\ 1\}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ \ \n\n\ \ \ \ proc\ count_members3\ list\ \{\n\ \ \ \ \ \ \ \ foreach\ x\ \$list\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ expr\ \{\[catch\ \{incr\ count(\$x)\}\]\ &&\ \[set\ count(\$x)\ 1\]\}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ \ \n\n\ \ \ \ proc\ count_members4\ list\ \{\n\ \ \ \ \ \ \ \ foreach\ x\ \$list\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ lappend\ ulist(\$x)\ \{\}\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ foreach\ name\ \[array\ names\ ulist\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ count(\$name)\ \[llength\ \$ulist(\$name)\]\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ \ \ \ \ \n\n\ \ \ \ proc\ count_members5\ list\ \{\n\ \ \ \ \ \ \ \ foreach\ x\ \$list\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ append\ ulist(\$x)\ .\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ \ foreach\ name\ \[array\ names\ ulist\]\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ count(\$name)\ \[string\ length\ \$ulist(\$name)\]\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\ \ \ \ \ \n\n\ \ \ \ #----------------------------------------\n\ \ \ \ #\ \ Create\ some\ test\ data.\ \ In\ this\ case,\n\ \ \ \ #\ \ build\ a\ list\ of\ 10,000\ items\n\ \ \ \ #----------------------------------------\n\ \ \ \ set\ items\ \[list\ john\ paul\ jones\ mary\]\n\ \ \ \ for\ \{set\ i\ 0\}\ \{\$i<10000\}\ \{incr\ i\}\ \{\n\ \ \ \ \ \ \ \ lappend\ data\ \[lindex\ \$items\ \[expr\ \{int(rand()*\[llength\ \$items\])\}\]\]\n\ \ \ \ \}\ \ \ \n\n\n\ \ \ \ #----------------------------------------\n\ \ \ \ #\ \ Print\ some\ information\ about\ our\n\ \ \ \ #\ \ environment.\ \ This\ is\ very\ useful\n\ \ \ \ #\ \ when\ consulting\ comp.lang.tcl.\n\ \ \ \ #----------------------------------------\n\ \ \ \ puts\ \"\[info\ patchlevel\]\ over\ \$tcl_platform(os)\ \$tcl_platform(osVersion).\"\n\n\n\ \ \ \ #----------------------------------------\n\ \ \ \ #\ \ Run\ the\ tests.\n\ \ \ \ #\ \ Note\ that\ we\ have\ cleverly\ named\n\ \ \ \ #\ \ the\ test\ procs\ so\ that\ \[info\]\ can\n\ \ \ \ #\ \ easily\ find\ and\ execute\ them.\n\ \ \ \ #----------------------------------------\n\ \ \ \ foreach\ proc\ \[info\ proc\ count_members*\]\ \{\n\ \ \ \ \ \ \ \ puts\ \"\"\n\ \ \ \ \ \ \ \ puts\ \"\$proc\"\n\ \ \ \ \ \ \ \ puts\ \[time\ \{\$proc\ \$data\}\ 10\]\n\ \ \ \ \}\n\n----\n\[RS\]\ 2004-02-20:\ Note\ however\ that\ the\ above\ procs\ don't\ really\ yield\ their\ count\ -\ the\ local\ array\ is\ discarded\ on\ \[return\].\ For\ practical\ use,\ I\ modified\ ''count_members4''\ which\ was\ among\ the\ fastest\ in\ my\ tests\ on\ WinXP,\ to\ return\ a\ list\ of\ \{element\ count\}\ pairs:\n\ proc\ lcount\ list\ \{\n\ \ \ \ foreach\ x\ \$list\ \{lappend\ arr(\$x)\ \{\}\}\n\ \ \ \ set\ res\ \{\}\n\ \ \ \ foreach\ name\ \[array\ names\ arr\]\ \{\n\ \ \ \ \ \ \ lappend\ res\ \[list\ \$name\ \[llength\ \$arr(\$name)\]\]\n\ \ \ \ \}\n\ \ \ \ return\ \$res\n\ \}\n\ %\ lcount\ \{yes\ no\ no\ present\ yes\ yes\ no\ no\ yes\ present\ yes\ no\ no\ yes\ yes\}\n\ \{no\ 6\}\ \{yes\ 7\}\ \{present\ 2\}\n\nThe\ list\ is\ in\ hash\ (i.e.,\ apparently\ no)\ order,\ but\ you\ can\ post-process\ it\ to\n\ \ \ *\ alphabetic:\ lsort\ \[\[lcount\ \$list\]\]\n\ \ \ *\ numeric:\ lsort\ -integer\ -index\ 1\ -decr\ \[\[lcount\ \$list\]\]\n----\nI\ don't\ have\ 8.5\ at\ hand\ yet,\ but\ I\ expect\ this\ \[dict\]\ version\ to\ be\ a\ good\ solution\ too:\n\ proc\ lcount\ list\ \{\n\ \ \ \ set\ count\ \{\}\n\ \ \ \ foreach\ element\ \$list\ \{dict\ incr\ count\ \$element\}\n\ \ \ \ set\ count\n\ \}\n----\n\n\[gold\]\nHere's\ counting\ through\ a\ list\ of\ thrown\ dice\ combos\nfor\ probability.\ The\ worker\ bee\ is\nlsearch\ -all\ \$lister\ \$facen\ \ \n\$facen\ is\ the\ sum\ of\ a\ 2-dice\ throw\ like\ 7.\nSubroutine\ is\ invoked\ by\ a\ foreach\ procedure\ \nfor\ probability,\ which\ would\ be\ number\ of\ thrown\ 7's\nover\ all\ possible\ throws\ (\$lister).\ \nDrop\ (-all)\ and\ lose\ all,\nreturning\ only\ one\ position\ of\ \"7\"\ in\ list.\nSee\ Binomial\ Probability\ Slot\ Calculator\ Example,\nhttp://wiki.tcl.tk/26724.\n======\n\ \ \ \ \ console\ show\n\ \ \ \ \ proc\ calculation\ \{\ \ facen\ \}\ \ \{\ \n\ \ \ \ \ #\ prob.\ subroutines\ for\ two\ 6-sided\ dice\n\ \ \ \ \ set\ lister\ \{2\ 3\ 4\ 5\ 6\ 7\ 3\ 4\ 5\ 6\ 7\ 8\ 4\ 5\ 6\ \ /\n\ \ \ \ \ 7\ 8\ 9\ 5\ 6\ 7\ 8\ 9\ 10\ 6\ 7\ 8\ 9\ 10\ 11\ 7\ 8\ 9\ 10\ 11\ 12\}\n\ \ \ \ \ set\ ee\ \[llength\ \ \$lister\ \]\n\ \ \ \ \ set\ kk\ \[\ llength\ \[\ lsearch\ -all\ \$lister\ \$facen\ \]\ \]\n\ \ \ \ \ set\ prob\ \[\ expr\ \{\ (\$kk*1.)\ /\ \$ee\ \ \}\ \]\n\ \ \ \ \ return\ \$prob\n\ \ \ \ \ \}\n\ \ \ \ \ \ \ \ \ \ set\ limit\ 12\n\ \ \ \ \ \ \ \ \ \ for\ \{\ set\ i\ 1\ \}\ \{\ \$i\ <=\ \$limit\ \}\ \ \{\ incr\ i\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ lappend\ listxxx\ \$i\ \n\ \ \ \ \ \ \ \ \ \ lappend\ listxxx\ \[\ calculation\ \ \$i\ \]\n\ \ \ \ \ \ \ \ \ \ puts\ \"\ \$i\ \[\ calculation\ \ \$i\ \]\ \"\n\ \ \ \ \ \ \ \ \ \ \}\n\ \ \ \ \ #end\n=====\n\n----\nSee\ \[Chart\ of\ proposed\ list\ functionality\]\ too.\n----\n\[Category\ Command\]} CALL {my revision {Counting Elements in a List}} CALL {::oo::Obj6141197 process revision/Counting+Elements+in+a+List} CALL {::oo::Obj6141195 process}

-errorcode

NONE

-errorinfo

Unknow state transition: LINE -> END
    while executing
"error $msg"
    (class "::Wiki" method "render_wikit" line 6)
    invoked from within
"my render_$default_markup $N $C $mkup_rendering_engine"
    (class "::Wiki" method "render" line 8)
    invoked from within
"my render $name $C"
    (class "::Wiki" method "revision" line 31)
    invoked from within
"my revision $page"
    (class "::Wiki" method "process" line 51)
    invoked from within
"$server process [string trim $uri /]"

-errorline

4