Email: nem AT cs.nott.ac.uk Web: http://www.cs.nott.ac.uk/~nem/ Location: Nottingham, UK. I am a PhD student at the University of Nottingham[http://www.cs.nott.ac.uk] in the UK and a Research Associate in the excitingly named Mixed Reality Lab[http://www.mrl.nott.ac.uk]. Pages I have created: * [A Coroutine-Enabled Interactive Command Line] * [A Paginated Canvas Widget] * [A Website-Specific Password Generator]. * [A little US election results mashup]. * [Coroutines for event-based programming]. * [Locally-scoped command aliases are fun!] * [Simple Records] * [A brief introduction to closures and continuations for event-based programming]. * [A plugin replacement for proc supporting lambdas and ensembles]. * [webrobot - a package for web scraping]. * [easywin - simplified toplevels]. * A parser for some of the file formats used in the [Neverwinter Nights] role-playing game. * [A lightweight digraph package] * [invoke] - a useful little proc I use all the time. * [dictutils] - a collection of useful procedures for dealing with [dict]s. * [A Thread-Safe Message Queue] - responding to a request on comp.lang.tcl. * [Monads] - a hopefully much clearer explanation of this tricky concept. * [A higher-level channel API]. * [Wrapping a procedure]. * [Using namespace ensemble without a namespace]. * [A lambda calculus interpreter with arithmetic]. * [A little learning decision tree]. * C# [using] construct in Tcl. * [A little database with unification]. * [A little logic notation editor]. * A description of [polymorphism]. * A proposal: [A generic collection traversal interface]. * Experimenting with a [Compositional Tk]. * A write-up of [Traits]: a compositional approach to [OO]. * Contributed some thoughts about the crucial reasons why [everything is a string]. * My take on [OO] - [TOOT]: [Transparent OO for Tcl]. (or Transparent Object Oriented Tcl). * The "philosophy" behind TOOT: [Interpreting TOOT] (but see also the comments on EIAS above). * Taking from ideas from [Haskell]: [Monadic TOOT] leads to [Parser Combinators]. * [Non-deterministic search] : A little play with automatic backtracking. * '''A vision for Tcl 9''': I am working on an essay with some ideas for Tcl 9. [http://www.cs.nott.ac.uk/~nem/fanatcl.html]. Update: this is a bit out of date, but most of the points are still valid. I've moved the essay to my univerity hosting for the time being: beware broken links! * [TkPool] (with a little help from [dkf]). * [Artificial Intelligence] * Old notes: [StarSite]/[ArTcl] * A little [BibTeX parser]. * [Parser Combinators]. * [Infix arithmetic with XOTcl]. * [Hello World as a C extension]. * [More functional programming] is my take on functional programming in Tcl. Ideas and discussion with Miguel and others lead to TIP 194 [http://tip.tcl.tk/194] and then to the generalisation that is [TOOT]. * [Simple Newsreader]. * [split and join for nested lists]. * [Simple Download Progress Widget] * Quickly knocked up [Transparent Toplevel] code for Windows... * [A Snit News Ticker Widget]. * Older: [Artificial Intelligence with Tcl], [State Space Searching in Tcl], [Heuristic Searches] ([RS] has a better version of these at [Searching A Star In Space]). These were partly based on psuedocode from the classic textbook "Artificial Intelligence: A Modern Approach" by Stuart Russell and Peter Norvig[http://aima.cs.berkeley.edu/], and were written while I was an undergraduate. A nice example of the usefulness of higher-order functions, even if I didn't know what that term meant at the time! * [Simple TkHTML Web Page Displayer]. * [Interfacing Tcl with Haskell]. * [Simple XML report writer]. ---- Experimenting with a Tcl version of 3-Lisp's reflective lambdas. In 3-Lisp, a reflective function receives 2 extra arguments: the environment of the caller and the continuation of the caller. IIRC, it also receives the other arguments in unevaluated form. This allows you to do ''loads'' of things: lazy evaluation, various kinds of meta programming etc. They are pretty much as powerful as Lisp macros, but I think they fit Tcl's model much better - e.g. they could be a replacement for [uplevel] that doesn't explicitly reference the stack. Anyway, here's a first stab at emulating them in current Tcl using uplevel/upvar: namespace eval meta { namespace export proc apply namespace ensemble create ::proc proc {name params body} { interp alias {} $name {} ::meta::apply [list $params $body ::] } ::proc apply {proc args} { set env [capturelevel 1] uplevel 1 [linsert $args 0 ::apply $proc $env] } ::proc capturelevel level { incr level set env [dict create] foreach name [uplevel $level { info vars }] { upvar $level $name value catch { dict set env $name $value } ;# no arrays } return $env } } This version is very limited: it captures the caller's variable environment as a [dict] and passes it to the meta-proc. So, read-only and variables-only. Still, it demonstrates the idea. Now, imagine this was read/write, and that the environment contained vars and commands. (Perhaps if we unified command/var names in Tcl 9?) Now also imagine that you get the current continuation as another arg... Example: % meta proc get {env name} { dict get $env $name } get % proc foo {a b} { puts "a = [get a], b = [get b]" } % foo 1 2 a = 1, b = 2 ---- ''21 Jan 2007'': A little filter I've been using for summarising undergraduate coursework marks. This is too trivial to deserve a page of its own, but I've found it useful on several occassions. Expects stdin to contain a single integer on each line, between 0-100, and generates a little statistical summary. Uses the [tcllib] math::statistics package, which makes things easy. package require math::statistics 0.2 namespace import math::statistics::basic-stats math::statistics::histogram proc % {value total} { expr {round($value/double($total)*100)} } set marks [split [string trim [read stdin]] \n] lassign [basic-stats $marks] mean min max num std var puts "Count: $num" puts "Max: $max" puts "Min: $min" puts "Mean: $mean" puts "Variance: $var" puts "Std. Dev.: $std" set bands [list 10 20 30 40 50 60 70 80 90] foreach band [linsert $bands 0 0] value [histogram $bands $marks] { puts [format {%2d-%2d: %-40s %3d (%2d%%)} $band [expr {$band+9}] \ [string repeat "#" $value] $value [% $value $num]] } Example output (from some random numbers): Count: 100 Max: 99.0 Min: 1.0 Mean: 50.19 Variance: 741.3675757575759 Std. Dev.: 27.22806595697858 0- 9: ####### 7 ( 7%) 10-19: ######### 9 ( 9%) 20-29: ################# 17 (17%) 30-39: ##### 5 ( 5%) 40-49: ############# 13 (13%) 50-59: ############## 14 (14%) 60-69: ########### 11 (11%) 70-79: ###### 6 ( 6%) 80-89: ######## 8 ( 8%) 90-99: ########## 10 (10%) ---- !!!!!! %| [Category Home Page] | [Category Person] |% !!!!!!