This tentative
tcllib module contains code to win decisively any programming language shootout that aims for unreadable compact code. i.e. the notorious class of 1 Liners
# 1liners.tcl
# $Id: 17768,v 1.10 2007-03-03 19:00:36 jcw Exp $
# cprt: comp.lang.tcl.*
# what: provide bragging tools for language shootouts.
# what: 42
# what:
# [http://groups.google.com/group/comp.lang.tcl/browse_frm/thread/facf8c58a9c7ab3]
proc 42 {} {
while {[gets stdin l]+1} {if {[append ($l) 1]==1} {puts $l}}
}
package provide 1liners 0.1
# end
# example:
package require 1liners
42
# end
UK: To make it clear, this is purely experimental code, for use during daring participations in language shootouts ;-)
RS fixed
append $(l) to be
append ($l) - what good is packaging if the contents aren't tested?
VK 02-mar-2007 unfortunately Tcl do not allow one-liners at all, in the sence that one could write small program directly from command line, like this one (word counter throughout entire file):
perl -w0777ne 'print scalar @{[/(\w+)/g]}' textfile
Many languages do allow this (even lisp)
I fail to see why above example with its
42 procedure helps with one-liner anyhow.
UK: Humor, it is a difficult concept. Read the google thread [
1] and my posting on c.l.t:[
2]