<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<feed xmlns="http://www.w3.org/2005/Atom">

	<title>Planet Scheme</title>
	<!--<link rel="self" type="text/atom" href=""/>-->
	<link rel="alternate" type="text/html" href="http://scheme.dk/planet/"/>
	<id></id>
	<updated>2012-02-04T12:01:04+00:00</updated>
	<generator uri="http://www.planetplanet.org/">http://intertwingly.net/code/venus/</generator>

	<entry>
		<title>Jeremy Kun: Cryptanalysis with N-Grams</title>
		<link rel="alternate" type="text/html" href="http://jeremykun.wordpress.com/2012/02/03/cryptanalysis-with-n-grams/"/>
		<id>http://jeremykun.wordpress.com/?p=1559</id>
		<updated>2012-02-03T19:52:16+00:00</updated>
		<content type="html">This post is the third post in a series on computing with natural language data sets. For the first two posts, see the relevant section of our main content page. A Childish Bit of Fun In this post, we focus … &lt;a href=&quot;http://jeremykun.wordpress.com/2012/02/03/cryptanalysis-with-n-grams/&quot;&gt;Continue reading &lt;span class=&quot;meta-nav&quot;&gt;→&lt;/span&gt;&lt;/a&gt;&lt;img src=&quot;http://stats.wordpress.com/b.gif?host=jeremykun.wordpress.com&amp;amp;blog=23934684&amp;amp;post=1559&amp;amp;subd=jeremykun&amp;amp;ref=&amp;amp;feed=1&quot; alt=&quot;&quot; height=&quot;1&quot; border=&quot;0&quot; width=&quot;1&quot; /&gt;</content>
		<author>
			<name>j2kun</name>
			<uri>http://jeremykun.wordpress.com</uri>
		</author>
	</entry>

	<entry>
		<title>Programming Praxis: Roman Numeral Puzzle</title>
		<link rel="alternate" type="text/html" href="http://programmingpraxis.com/2012/02/03/roman-numeral-puzzle/"/>
		<id>http://programmingpraxis.com/?p=5357</id>
		<updated>2012-02-03T09:00:27+00:00</updated>
		<content type="html">&lt;p&gt;The Super Bowl is the championship game of the American league of professional football teams — and an annual cultural event. The first Super Bowl, won by the Green Bay Packers under head coach Vince Lombardi, was in 1967, and wasn’t even called “Super Bowl” at the time; the name didn’t attach to the game until Super Bowl III, when Joe Namath of the New York Jets guaranteed a victory. Roman numerals have been used to designate the Super Bowl ever since. The game this year, between the Boston Patriots and New York Giants, is Super Bowl XLVI; you can solve today’s exercise while you watch the game on Sunday evening.&lt;/p&gt;
&lt;p&gt;John D. Cook turned the wacky roman numerals of the Super Bowl into an &lt;a href=&quot;http://www.johndcook.com/blog/2012/01/14/roman-numeral-puzzle/&quot;&gt;exercise&lt;/a&gt; at his blog; he was inspired by an advertisement for Super Bowl XLVI on a pizza box. Cook asked his readers to compute how many numbers can be expressed as roman numerals without duplicating any of the symbols I, V, X, L, C, D or M.&lt;/p&gt;
&lt;p&gt;Your task is to compute the number of roman numerals that have no duplicate characters. When you are finished, you are welcome to &lt;a href=&quot;http://programmingpraxis.com/2012/02/03/roman-numeral-puzzle/2/&quot;&gt;read&lt;/a&gt; or &lt;a href=&quot;http://programmingpraxis.codepad.org/YStV3byV&quot;&gt;run&lt;/a&gt; a suggested solution, or to post your own solution or discuss the exercise in the comments below.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/programmingpraxis.wordpress.com/5357/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/comments/programmingpraxis.wordpress.com/5357/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/programmingpraxis.wordpress.com/5357/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/delicious/programmingpraxis.wordpress.com/5357/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/programmingpraxis.wordpress.com/5357/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/facebook/programmingpraxis.wordpress.com/5357/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/programmingpraxis.wordpress.com/5357/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/twitter/programmingpraxis.wordpress.com/5357/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/programmingpraxis.wordpress.com/5357/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/stumble/programmingpraxis.wordpress.com/5357/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/programmingpraxis.wordpress.com/5357/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/digg/programmingpraxis.wordpress.com/5357/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/programmingpraxis.wordpress.com/5357/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/reddit/programmingpraxis.wordpress.com/5357/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;img src=&quot;http://stats.wordpress.com/b.gif?host=programmingpraxis.com&amp;amp;blog=6649073&amp;amp;post=5357&amp;amp;subd=programmingpraxis&amp;amp;ref=&amp;amp;feed=1&quot; alt=&quot;&quot; height=&quot;1&quot; border=&quot;0&quot; width=&quot;1&quot; /&gt;</content>
		<author>
			<name>programmingpraxis</name>
			<uri>http://programmingpraxis.com</uri>
		</author>
	</entry>

	<entry>
		<title>Jeremy Kun: The Fundamental Theorem of Algebra (with Galois Theory)</title>
		<link rel="alternate" type="text/html" href="http://jeremykun.wordpress.com/2012/02/02/the-fundamental-theorem-of-algebra-galois-theory/"/>
		<id>http://jeremykun.wordpress.com/?p=1635</id>
		<updated>2012-02-03T04:42:11+00:00</updated>
		<content type="html">This post assumes familiarity with some basic concepts in abstract algebra, specifically the terminology of field extensions, and the classical results in Galois theory and group theory. The fundamental theorem of algebra has quite a few number of proofs (enough … &lt;a href=&quot;http://jeremykun.wordpress.com/2012/02/02/the-fundamental-theorem-of-algebra-galois-theory/&quot;&gt;Continue reading &lt;span class=&quot;meta-nav&quot;&gt;→&lt;/span&gt;&lt;/a&gt;&lt;img src=&quot;http://stats.wordpress.com/b.gif?host=jeremykun.wordpress.com&amp;amp;blog=23934684&amp;amp;post=1635&amp;amp;subd=jeremykun&amp;amp;ref=&amp;amp;feed=1&quot; alt=&quot;&quot; height=&quot;1&quot; border=&quot;0&quot; width=&quot;1&quot; /&gt;</content>
		<author>
			<name>j2kun</name>
			<uri>http://jeremykun.wordpress.com</uri>
		</author>
	</entry>

	<entry>
		<title>PLT Scheme: Racket v5.2.1</title>
		<link rel="alternate" type="text/html" href="http://blog.racket-lang.org/2012/02/racket-v521.html"/>
		<id>tag:blogger.com,1999:blog-2080885971644496896.post-2390508687802287055</id>
		<updated>2012-02-02T20:30:51+00:00</updated>
		<content type="html">Racket version 5.2.1 is now available from
&lt;pre&gt;&lt;a href=&quot;http://racket-lang.org/&quot;&gt;http://racket-lang.org/&lt;/a&gt;&lt;/pre&gt;
&lt;h2&gt;Release Highlights:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Performance improvements include the use of &lt;tt&gt;epoll()&lt;/tt&gt;/&lt;tt&gt;kqueue()&lt;/tt&gt; instead of &lt;tt&gt;select()&lt;/tt&gt; for the Racket thread scheduler, cross-module inlining of small functions, and the use of SSE instead of x87 for JIT-compiled floating-point operations on platforms where SSE is always available (including x86_64 platforms).  A related change is the interning of literal numbers, strings, byte strings, characters, and regexps that appear in code and syntax objects.&lt;/li&gt;
&lt;li&gt;DrRacket uses a set of composable ray-traced icons available from the new &lt;tt&gt;images&lt;/tt&gt; library collection.&lt;/li&gt;
&lt;li&gt;Typed Racket's &lt;tt&gt;typecheck-fail&lt;/tt&gt; form allows macro creators to customize the error messages that Typed Racket produces.  This is especially useful when creating pattern matching macros.&lt;/li&gt;
&lt;li&gt;The performance of Redex's matcher has been substantially improved; depending on the model you should see improvements between 2x and 50x in the time it takes to reduce terms.&lt;/li&gt;
&lt;li&gt;Plots look nicer and are more correct at very small and very large scales.  New features include customizable dual axis ticks and transforms (e.g., log axes, date and currency ticks, axis interval collapse and stretch), stacked histograms, and 3D vector fields.  The legacy &lt;tt&gt;fit&lt;/tt&gt; function and libfit have been removed.&lt;/li&gt;
&lt;li&gt;The &lt;tt&gt;2htdp/universe&lt;/tt&gt; library's &lt;tt&gt;big-bang&lt;/tt&gt; form supports an experimental game pad key handler.&lt;/li&gt;
&lt;li&gt;The &lt;tt&gt;db&lt;/tt&gt; library now supports nested transactions and PostgreSQL arrays.  Bugs involving MySQL authentication and memory corruption in the SQLite bindings have been fixed.&lt;/li&gt;
&lt;li&gt;The Macro Stepper tool in DrRacket no longer executes a program after expanding it.&lt;/li&gt;
&lt;li&gt;In the DMdA teaching languages, infinite recursive signatures (&quot;streams&quot;, for example) with no intervening &lt;tt&gt;mixed&lt;/tt&gt; are now supported, and the signatures of record definitions without fields now have generators for use with &lt;tt&gt;property&lt;/tt&gt;.&lt;/li&gt;
&lt;li&gt;MysterX's ActiveX support is deprecated and will be removed in the next release.  MysterX's core COM functionality will become deprecated in the next release, but COM functionality will be supported for the foreseeable future as a compatibility layer over a forthcoming &lt;tt&gt;ffi/com&lt;/tt&gt; library.&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/tracker/2080885971644496896-2390508687802287055?l=blog.racket-lang.org&quot; alt=&quot;&quot; height=&quot;1&quot; width=&quot;1&quot; /&gt;&lt;/div&gt;</content>
		<author>
			<name>Eli Barzilay (noreply@blogger.com)</name>
			<uri>http://blog.racket-lang.org/</uri>
		</author>
	</entry>

	<entry>
		<title>PLT Scheme: Zack Galler's Experience with Stateful vs Stateless Web Apps</title>
		<link rel="alternate" type="text/html" href="http://blog.racket-lang.org/2012/02/zack-gallers-experience-with-stateful.html"/>
		<id>tag:blogger.com,1999:blog-2080885971644496896.post-2611538924601880099</id>
		<updated>2012-02-02T02:46:59+00:00</updated>
		<content type="html">&lt;p&gt;Communication using HTTP between client and server is a simple problem of halted computation.&lt;/p&gt;
&lt;p&gt;A client computes a request, transmits and halts, waiting for a server response.  On receipt, the server computes a response, transmits and halts, waiting for the next client request.&lt;/p&gt;
&lt;p&gt;This much is well known.&lt;/p&gt;
&lt;p&gt;Racket's magnificent &lt;em&gt;stateful&lt;/em&gt; Web server does three things on the server side:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;it &lt;b&gt;reifies&lt;/b&gt; a Racket continuation, capturing where the server computation has halted.&lt;/li&gt;
&lt;li&gt;it &lt;b&gt;externalizes&lt;/b&gt; the continuation, creating  a URL-representation that uniquely maps to the Racket continuation&lt;/li&gt;
&lt;li&gt;it &lt;b&gt;disseminates&lt;/b&gt; the externalized continuation to interested clients, typically via HTTP response, but alternately via SMTP or any other protocol.&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Then, it waits.&lt;/p&gt;
&lt;p&gt;Later, when &lt;b&gt;presented&lt;/b&gt; with an externalized continuation, a quick inverse mapping occurs, the underlying Racket continuation is &lt;b&gt;invoked,&lt;/b&gt; and the server processes the new client request.&lt;/p&gt;
&lt;p&gt;Rinse and repeat.&lt;/p&gt;
&lt;p&gt;The problem with this approach is twofold&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;the reified Racket continuations live in server memory.  And there's no safe way to garbage collect, as the continuations could be invoked at any time.  There are strategies to reclaim memory, but &lt;em&gt;some&lt;/em&gt; load level will noticeably decrease the performance of your application.  And its not possible to figure out what that load level is prior to finishing your application.  This is a problem.&lt;/li&gt;
&lt;li&gt;Again, the reified Racket continuations live in server memory and cannot be moved.  So there's no way to scale an application to more than one server.  It's a necessarily one machine system.  This makes problem #1 worse.&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Racket's yet more magnificent &lt;em&gt;stateless&lt;/em&gt; Web server does exactly the same three things:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;to &lt;b&gt;reify&lt;/b&gt;, it rewrites the entire call stack into a format known as &lt;a href=&quot;https://en.wikipedia.org/wiki/Administrative_normal_form&quot;&gt;A-Normal Form&lt;/a&gt; (ANF).&lt;/li&gt;
&lt;li&gt;to &lt;b&gt;externalize&lt;/b&gt;, the ANF'd stack is encoded for transmission over HTTP.&lt;/li&gt;
&lt;li&gt;and then it's sent over to the client (&lt;b&gt;dissemination&lt;/b&gt;).&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Later, when &lt;b&gt;presented&lt;/b&gt; with encoded stack, the stateless server performs an inverse transform to &lt;b&gt;reconstruct&lt;/b&gt; the call stack, at which point the server keeps going.&lt;/p&gt;
&lt;p&gt;So we've lost the &lt;b&gt;invocation&lt;/b&gt; step and substituted a &lt;b&gt;reconstruction&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;But in exchange, we've eliminated continuations from server memory, and solved both enumerated problems above.  Neat trick.&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;I provide a few lessons learned for the archives for the next person to attempt porting &lt;tt&gt;#lang racket&lt;/tt&gt; to &lt;tt&gt;#lang web-server&lt;/tt&gt; code.&lt;/p&gt;
&lt;p&gt;First, the predicate &lt;tt&gt;serializable?&lt;/tt&gt; from &lt;tt&gt;racket/serialize&lt;/tt&gt; is invaluable.  The &lt;tt&gt;#lang web-server&lt;/tt&gt; code will not transform if there are non-serializable constructs in the dynamic extent of the invocation of &lt;tt&gt;send/suspend&lt;/tt&gt;, such as a local binding or argument.&lt;/p&gt;
&lt;p&gt;Second, invocations of native continuations reified with &lt;tt&gt;call/cc&lt;/tt&gt; frequently throw errors related to continuation prompts, such as “attempt to cross a continuation barrier” or “no corresponding prompt tag in continuation”.  In all cases, I was able to remedy the situation by enclosing the invocation in &lt;tt&gt;call-with-continuation-prompt&lt;/tt&gt;.  This may be an error in the system, but it is unclear at this time.&lt;/p&gt;
&lt;p&gt;Third, the transformation does not allow parameters or &lt;tt&gt;dynamic-wind&lt;/tt&gt;, because the internal data-structures representing them are not serializable, but continuation-marks can be used to reimplement the piece of the functionality you need.&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;Finally, thank you to the Racket team.  I think the stateless Web language is important technology and must have required an enormous amount of work to implement.&lt;/p&gt;
&lt;p&gt;Anecdotally, application speed seems at or better than the stateful code.&lt;/p&gt;
&lt;p&gt;To learn more about the stateless Web application infrastructure, &lt;a href=&quot;http://docs.racket-lang.org/web-server/stateless.html&quot;&gt;consult the manual&lt;/a&gt; or post to the &lt;a href=&quot;http://lists.racket-lang.org/&quot;&gt;mailing list&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;(This post was written by Zack Galler with minor edits before posting by Jay McCarthy.)&lt;/i&gt;&lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/tracker/2080885971644496896-2611538924601880099?l=blog.racket-lang.org&quot; alt=&quot;&quot; height=&quot;1&quot; width=&quot;1&quot; /&gt;&lt;/div&gt;</content>
		<author>
			<name>Jay McCarthy (noreply@blogger.com)</name>
			<uri>http://blog.racket-lang.org/</uri>
		</author>
	</entry>

	<entry>
		<title>Andy Wingo: eval, that spectral hound</title>
		<link rel="alternate" type="text/html" href="http://wingolog.org/archives/2012/02/01/eval-that-spectral-hound"/>
		<id>http://wingolog.org/2012/02/01/eval-that-spectral-hound</id>
		<updated>2012-02-01T15:33:49+00:00</updated>
		<content type="html">&lt;div&gt;&lt;p&gt;Friends, I am not a free man.  Eval has been my companion of late, a hellhound on my hack-trail.  I give you two instances.&lt;/p&gt;&lt;p&gt;&lt;b&gt;the howl of the-environment, across the ages&lt;/b&gt;&lt;/p&gt;&lt;p&gt;As legend has it, in the olden days, Aubrey Jaffer, the duke of &lt;a href=&quot;http://people.csail.mit.edu/jaffer/SCM&quot;&gt;SCM&lt;/a&gt;, introduced low-level &lt;a href=&quot;http://en.wikipedia.org/wiki/Fexpr&quot;&gt;FEXPR&lt;/a&gt;-like macros into his Scheme implementation.  These allowed users to capture the lexical environment:&lt;/p&gt;&lt;pre&gt;
(define the-environment
  (&lt;a href=&quot;http://people.csail.mit.edu/jaffer/scm/Macro-Primitives.html#index-procedure_002d_003esyntax-281&quot;&gt;procedure-&amp;gt;syntax&lt;/a&gt;
   (lambda (exp env)
     env)))
&lt;/pre&gt;&lt;p&gt;Tom Lord inherited this cursed bequest from Jaffer, when he established himself in the nearby earldom of Guile.  It so affected him that he added &lt;a href=&quot;http://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Local-Evaluation.html#index-local_002deval-2270&quot;&gt;&lt;tt&gt;local-eval&lt;/tt&gt;&lt;/a&gt; to Guile, allowing the user to evaluate an expression within a captured local environment:&lt;/p&gt;&lt;pre&gt;
(define env (let ((x 10)) (the-environment)))
(local-eval 'x env)
=&amp;gt; 10
(local-eval '(set! x 42) env)
(local-eval 'x env)
=&amp;gt; 42
&lt;/pre&gt;&lt;p&gt;Since then, the tenants of the earldom of Guile have been haunted by this strange leakage of the state of the interpreter into the semantics of Guile.&lt;/p&gt;&lt;p&gt;When the Guile co-maintainer title devolved upon me, I had a plan to vanquish the hound: to compile Guile into fast bytecode.  There would be no inefficient association-lists of bindings at run-time.  Indeed, there would be no &quot;environment object&quot; to capture.  I succeeded, and with Guile 2.0, &lt;tt&gt;local-eval&lt;/tt&gt;, &lt;tt&gt;procedure-&amp;gt;syntax&lt;/tt&gt; and &lt;tt&gt;the-environment&lt;/tt&gt; were &lt;a href=&quot;http://git.savannah.gnu.org/cgit/guile.git/tree/NEWS?h=stable-2.0&amp;amp;id=7e9a301b7f3bcc811803305250b22d71a8b06155#n924&quot;&gt;no more&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;But no.  As Guile releases started to make it into distributions, and users started to update their code, there arose such a howling on the mailing lists as set my hair on end.  The ghost of &lt;tt&gt;local-eval&lt;/tt&gt; was calling: it would not be laid to rest.&lt;/p&gt;&lt;p&gt;I resisted fate, for as long as I could do so in good conscience.  In the end, Guile hacker Mark Weaver led an expedition to the mailing list moor, and came back with a plan.&lt;/p&gt;&lt;p&gt;Mark's plan was to have the syntax expander recognize &lt;tt&gt;the-environment&lt;/tt&gt;, and residualize a form that would capture the identities of all lexical bindings.  Like this:&lt;/p&gt;&lt;pre&gt;
(let ((x 10)) (the-environment))
=&amp;gt;
(let ((x 10))
  (make-lexical-environment
   ;; Procedure to wrap captured environment around
   ;; an expression
   &lt;i&gt;wrapper&lt;/i&gt;
   ;; Captured variables: only &quot;x&quot; in this case
   (list (capture x))))
&lt;/pre&gt;&lt;p&gt;I'm taking it a little slow because hey, this is some tricky macrology.  Let's look at &lt;tt&gt;(capture x)&lt;/tt&gt; first.  How do you capture a variable?  In Scheme, with a closure.  Like this:&lt;/p&gt;&lt;pre&gt;
;; Capture a variable with a closure.
;;
(define-syntax-rule (capture var)
  (case-lambda
    ;; When called with no arguments, return the value
    ;; of VAR.
    (() var)
    ;; When called with one argument, set the VAR to the
    ;; new value.
    ((new-val) (set! var new-val))))
&lt;/pre&gt;&lt;p&gt;The trickier part is reinstating the environment, so that &lt;tt&gt;x&lt;/tt&gt; in a local-eval'd expression results in the invocation of a closure.  &lt;a href=&quot;http://www.gnu.org/software/guile/manual/html_node/Identifier-Macros.html#index-identifier_002dsyntax-1899&quot;&gt;Identifier syntax&lt;/a&gt; to the rescue:&lt;/p&gt;&lt;pre&gt;
;; The &lt;i&gt;wrapper&lt;/i&gt; from above: a procedure that wraps
;; an expression in a lexical environment containing &lt;i&gt;x&lt;/i&gt;.
;;
(lambda (exp)
  #`(lambda (x*) ; x* is a fresh temporary var
      (let-syntax ((x (identifier-syntax
                        (_ (x*))
                        ((set! _ val) (x* val)))))
        #,exp)))
&lt;/pre&gt;&lt;p&gt;By now it's clear what &lt;tt&gt;local-eval&lt;/tt&gt; does: it wraps an expression, using the wrapper procedure from the environment object, evaluates that expression, then calls the resulting procedure with the case-lambda closures that captured the lexical variable.&lt;/p&gt;&lt;p&gt;So it's a bit intricate and nasty in some places, but hey, it finally tames the ghostly hound with modern Scheme.  We were able to build &lt;a href=&quot;http://www.gnu.org/software/guile/manual/html_node/Local-Evaluation.html&quot;&gt;&lt;tt&gt;local-eval&lt;/tt&gt;&lt;/a&gt; on top of Guile's procedural macros, once a couple of accessors were added to our expander to return the set of bound identifiers visible in an expression, and to query whether those bindings were regular lexicals, or macros, or pattern variables, or whatever.&lt;/p&gt;&lt;p&gt;&lt;b&gt;&quot;watson, your service revolver, please.&quot;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;As that Guile discussion was winding down, I started to hear the howls from an unexpected quarter: JavaScript.  You might have heard, perhaps, that &lt;a href=&quot;http://wingolog.org/archives/2012/01/12/javascript-eval-considered-crazy&quot;&gt;JavaScript eval is crazy&lt;/a&gt;.  Well, it is.  But ES5 strict was meant to kill off its most egregious aspect, in which eval can introduce new local variables to a function.&lt;/p&gt;&lt;p&gt;Now I've been slowly hacking on implementing block-scoped &lt;tt&gt;let&lt;/tt&gt; and &lt;tt&gt;const&lt;/tt&gt; in JavaScriptCore, so that we can consider switching &lt;a href=&quot;http://live.gnome.org/GnomeShell&quot;&gt;gnome-shell&lt;/a&gt; over to use JSC.  Beyond standard ES5 supported in JSC, existing gnome-shell code uses &lt;tt&gt;let&lt;/tt&gt;, &lt;tt&gt;const&lt;/tt&gt;, destructuring binding, and modules, all of which are bound to be standardized in the upcoming ES6.  So, off to the hack.&lt;/p&gt;&lt;p&gt;My initial approach was to produce a correct implementation, and then make it fast.  But the JSC maintainers, inspired by the idea that &quot;&lt;tt&gt;let&lt;/tt&gt; is the new &lt;tt&gt;var&lt;/tt&gt;&quot;, wanted to ensure that &lt;tt&gt;let&lt;/tt&gt; was fast from the beginning, so that it doesn't get a bad name with developers.  OK, fair enough!&lt;/p&gt;&lt;p&gt;Beyond that, though, it looks like TC39 folk are eager to get &lt;tt&gt;let&lt;/tt&gt; and &lt;tt&gt;const&lt;/tt&gt; into all parts of JavaScript, not just strict mode.  Do you hear the hound?  It rides again!  Now we have to figure out how block scope interacts with non-strict eval.  Awooooo!&lt;/p&gt;&lt;p&gt;Thankfully, there seems to be a developing consensus that &lt;tt&gt;eval(&quot;let x = 20&quot;)&lt;/tt&gt; will &lt;i&gt;not&lt;/i&gt; introduce a new block-scoped lexical.  So, down boy.  The hound is at bay, for now.&lt;/p&gt;&lt;p&gt;&lt;b&gt;life with dogs&lt;/b&gt;&lt;/p&gt;&lt;p&gt;I'm making my peace with eval.  Certainly in JavaScript it's quite a burden for an implementor, but the current ES6 drafts don't look like they're making the problem worse.  And in Scheme, I'm very happy to provide the &lt;a href=&quot;http://www.gnu.org/software/guile/manual/html_node/Syntax-Transformer-Helpers.html&quot;&gt;primitives&lt;/a&gt; needed so that local-eval can be implemented in terms of our existing machinery, without needing symbol tables at runtime.  But if you are making a new language, as you value your life, don't go walking on the local-eval moors at night!&lt;/p&gt;&lt;/div&gt;</content>
		<author>
			<name>Andy Wingo</name>
			<uri>http://wingolog.org/</uri>
		</author>
	</entry>

	<entry>
		<title>Programming Praxis: String Rotation</title>
		<link rel="alternate" type="text/html" href="http://programmingpraxis.com/2012/01/31/string-rotation/"/>
		<id>http://programmingpraxis.com/?p=5393</id>
		<updated>2012-01-31T09:00:41+00:00</updated>
		<content type="html">&lt;p&gt;We have today another question from our never-ending supply of interview questions:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Write a function that takes two input strings and determines if one is a rotation of the other. For instance, “ProgrammingPraxis” and “PraxisProgramming” are rotations of each other, but “ProgrammingPrasix” is not a rotation of “ProgrammingPraxis” because the last three letters are out of order.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Your task is to write the requested function. When you are finished, you are welcome to &lt;a href=&quot;http://programmingpraxis.com/2012/01/31/string-rotation/2/&quot;&gt;read&lt;/a&gt; or &lt;a href=&quot;http://programmingpraxis.codepad.org/e2h1UyvF&quot;&gt;run&lt;/a&gt; a suggested solution, or to post your own solution or discuss the exercise in the comments below.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/programmingpraxis.wordpress.com/5393/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/comments/programmingpraxis.wordpress.com/5393/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/programmingpraxis.wordpress.com/5393/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/delicious/programmingpraxis.wordpress.com/5393/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/programmingpraxis.wordpress.com/5393/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/facebook/programmingpraxis.wordpress.com/5393/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/programmingpraxis.wordpress.com/5393/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/twitter/programmingpraxis.wordpress.com/5393/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/programmingpraxis.wordpress.com/5393/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/stumble/programmingpraxis.wordpress.com/5393/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/programmingpraxis.wordpress.com/5393/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/digg/programmingpraxis.wordpress.com/5393/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/programmingpraxis.wordpress.com/5393/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/reddit/programmingpraxis.wordpress.com/5393/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;img src=&quot;http://stats.wordpress.com/b.gif?host=programmingpraxis.com&amp;amp;blog=6649073&amp;amp;post=5393&amp;amp;subd=programmingpraxis&amp;amp;ref=&amp;amp;feed=1&quot; alt=&quot;&quot; height=&quot;1&quot; border=&quot;0&quot; width=&quot;1&quot; /&gt;</content>
		<author>
			<name>programmingpraxis</name>
			<uri>http://programmingpraxis.com</uri>
		</author>
	</entry>

	<entry>
		<title>Jeremy Kun: Handshake Lemma</title>
		<link rel="alternate" type="text/html" href="http://jeremykun.wordpress.com/2012/01/29/handshake-lemma/"/>
		<id>http://jeremykun.wordpress.com/?p=1620</id>
		<updated>2012-01-30T04:24:31+00:00</updated>
		<content type="html">Problem: Prove or disprove: at a party of people, there must be an even number of people who have an odd number of friends at the party. Solution: Let be the set of all people, and for any person , … &lt;a href=&quot;http://jeremykun.wordpress.com/2012/01/29/handshake-lemma/&quot;&gt;Continue reading &lt;span class=&quot;meta-nav&quot;&gt;→&lt;/span&gt;&lt;/a&gt;&lt;img src=&quot;http://stats.wordpress.com/b.gif?host=jeremykun.wordpress.com&amp;amp;blog=23934684&amp;amp;post=1620&amp;amp;subd=jeremykun&amp;amp;ref=&amp;amp;feed=1&quot; alt=&quot;&quot; height=&quot;1&quot; border=&quot;0&quot; width=&quot;1&quot; /&gt;</content>
		<author>
			<name>j2kun</name>
			<uri>http://jeremykun.wordpress.com</uri>
		</author>
	</entry>

	<entry>
		<title>Programming Praxis: Anagram Phrases</title>
		<link rel="alternate" type="text/html" href="http://programmingpraxis.com/2012/01/27/anagram-phrases/"/>
		<id>http://programmingpraxis.com/?p=5380</id>
		<updated>2012-01-27T09:00:43+00:00</updated>
		<content type="html">&lt;p&gt;Words that are formed from the same set of letters are anagrams of each other. For instance, pots, post, stop, spot, opts, and tops are anagrams. We studied anagrams in a &lt;a href=&quot;http://programmingpraxis.com/2009/04/10/anagrams/&quot;&gt;previous exercise&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Anagrams can be extended from single words to phrases. For instance, “gin grammar prop six” and “maxim prong rasp rig” are anagrams for “programming praxis.”&lt;/p&gt;
&lt;p&gt;Your task is to write a program to find all the anagram phrases for an input phrase that are present in a given dictionary; show only one permutation of each set of unique words. When you are finished, you are welcome to &lt;a href=&quot;http://programmingpraxis.com/2012/01/27/anagram-phrases/2/&quot;&gt;read&lt;/a&gt; or &lt;a href=&quot;http://programmingpraxis.codepad.org/CBWq8vut&quot;&gt;run&lt;/a&gt; a suggested solution, or to post your own solution or discuss the exercise in the comments below.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/programmingpraxis.wordpress.com/5380/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/comments/programmingpraxis.wordpress.com/5380/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/programmingpraxis.wordpress.com/5380/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/delicious/programmingpraxis.wordpress.com/5380/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/programmingpraxis.wordpress.com/5380/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/facebook/programmingpraxis.wordpress.com/5380/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/programmingpraxis.wordpress.com/5380/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/twitter/programmingpraxis.wordpress.com/5380/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/programmingpraxis.wordpress.com/5380/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/stumble/programmingpraxis.wordpress.com/5380/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/programmingpraxis.wordpress.com/5380/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/digg/programmingpraxis.wordpress.com/5380/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/programmingpraxis.wordpress.com/5380/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/reddit/programmingpraxis.wordpress.com/5380/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;img src=&quot;http://stats.wordpress.com/b.gif?host=programmingpraxis.com&amp;amp;blog=6649073&amp;amp;post=5380&amp;amp;subd=programmingpraxis&amp;amp;ref=&amp;amp;feed=1&quot; alt=&quot;&quot; height=&quot;1&quot; border=&quot;0&quot; width=&quot;1&quot; /&gt;</content>
		<author>
			<name>programmingpraxis</name>
			<uri>http://programmingpraxis.com</uri>
		</author>
	</entry>

	<entry>
		<title>Alaric Snell-Pym: Alaric’s projects for this year</title>
		<link rel="alternate" type="text/html" href="http://www.snell-pym.org.uk/archives/2012/01/26/alarics-projects-for-this-year/"/>
		<id>http://www.snell-pym.org.uk/?p=2750</id>
		<updated>2012-01-26T17:09:46+00:00</updated>
		<content type="html">This year's going to be pretty busy with settling into the new home, but I have a few projects.


Finish the ring casting I nearly finished before the move. That's a priority.
Resurrect my aluminium foundry. In particular, it's our bronze wedding anniversary, so Sarah's going to design a pattern for a sundial, which I will cast [...]</content>
		<author>
			<name>alaric</name>
			<uri>http://www.snell-pym.org.uk</uri>
		</author>
	</entry>

	<entry>
		<title>Programming Praxis: A Dozen Lines Of Code</title>
		<link rel="alternate" type="text/html" href="http://programmingpraxis.com/2012/01/24/a-dozen-lines-of-code/"/>
		<id>http://programmingpraxis.com/?p=5341</id>
		<updated>2012-01-24T09:00:56+00:00</updated>
		<content type="html">&lt;p&gt;Today’s task will require your imagination and creativity.&lt;/p&gt;
&lt;p&gt;A high-school programming teacher recently &lt;a href=&quot;http://stackoverflow.com/questions/811074/what-is-the-coolest-thing-you-can-do-in-10-lines-of-simple-code-help-me-inspir&quot;&gt;asked&lt;/a&gt; for examples of short programs with a high “cool” factor, the idea being to get his students interested in programming computers. I’m not sure the suggestions would work; today’s high-school students have been surrounded by computers their entire lives, and it takes a lot to make them think a program is cool. Being from a different generation, I can remember when I thought it was cool that a program properly skipped over the perforation on a stack of green-bar paper — many programs didn’t!&lt;/p&gt;
&lt;p&gt;Your task is to write a cool program in a dozen lines of code. You can define cool in any way that you wish. Try not to abuse the definition of “line of code,” at least not too badly; to be concrete, we will say that your solution must not exceed 12 lines, and each line must not exceed 80 characters including white space. When you are finished, you are welcome to &lt;a href=&quot;http://programmingpraxis.com/2012/01/24/a-dozen-lines-of-code/2/&quot;&gt;read&lt;/a&gt; or &lt;a href=&quot;http://programmingpraxis.codepad.org/soelfszm&quot;&gt;run&lt;/a&gt; a suggested solution, or to post your own solution or discuss the exercise in the comments below.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/programmingpraxis.wordpress.com/5341/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/comments/programmingpraxis.wordpress.com/5341/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/programmingpraxis.wordpress.com/5341/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/delicious/programmingpraxis.wordpress.com/5341/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/programmingpraxis.wordpress.com/5341/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/facebook/programmingpraxis.wordpress.com/5341/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/programmingpraxis.wordpress.com/5341/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/twitter/programmingpraxis.wordpress.com/5341/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/programmingpraxis.wordpress.com/5341/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/stumble/programmingpraxis.wordpress.com/5341/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/programmingpraxis.wordpress.com/5341/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/digg/programmingpraxis.wordpress.com/5341/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/programmingpraxis.wordpress.com/5341/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/reddit/programmingpraxis.wordpress.com/5341/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;img src=&quot;http://stats.wordpress.com/b.gif?host=programmingpraxis.com&amp;amp;blog=6649073&amp;amp;post=5341&amp;amp;subd=programmingpraxis&amp;amp;ref=&amp;amp;feed=1&quot; alt=&quot;&quot; height=&quot;1&quot; border=&quot;0&quot; width=&quot;1&quot; /&gt;</content>
		<author>
			<name>programmingpraxis</name>
			<uri>http://programmingpraxis.com</uri>
		</author>
	</entry>

	<entry>
		<title>Grant Rettke: NexJ Scheme</title>
		<link rel="alternate" type="text/html" href="http://www.wisdomandwonder.com/link/6135/nexj-scheme"/>
		<id>http://www.wisdomandwonder.com/?p=6135</id>
		<updated>2012-01-23T03:08:47+00:00</updated>
		<content type="html">&lt;blockquote&gt;&lt;p&gt;&lt;a href=&quot;http://nexj-scheme.org/&quot;&gt;NexJ&lt;/a&gt; Scheme is an open source project providing an efficient and powerful interpreter for the programming language Scheme that executes in a Java virtual machine.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Today I was sort of shocked to learn that there is another implementation besides &lt;a href=&quot;http://sisc-scheme.org/&quot;&gt;SISC&lt;/a&gt; and &lt;a href=&quot;http://www.gnu.org/software/kawa/&quot;&gt;Kawa&lt;/a&gt; that runs on Java!&lt;/p&gt;
&lt;p&gt;There wasn’t even an announcement for NexJ on comp.lang.scheme and NexJ has been around for two years :(! Rather it was mentioned on scheme-reports this week.&lt;/p&gt;</content>
		<author>
			<name>Grant</name>
			<uri>http://www.wisdomandwonder.com</uri>
		</author>
	</entry>

	<entry>
		<title>Jeremy Kun: The Fundamental Theorem of Algebra (with the Fundamental Group)</title>
		<link rel="alternate" type="text/html" href="http://jeremykun.wordpress.com/2012/01/22/the-fundamental-theorem-of-algebra-with-the-fundamental-group/"/>
		<id>http://jeremykun.wordpress.com/?p=1569</id>
		<updated>2012-01-22T20:46:13+00:00</updated>
		<content type="html">This post assumes familiarity with some basic concepts in algebraic topology, specifically what a group is and the definition of the fundamental group of a topological space. The fundamental theorem of algebra has quite a few number of proofs (enough … &lt;a href=&quot;http://jeremykun.wordpress.com/2012/01/22/the-fundamental-theorem-of-algebra-with-the-fundamental-group/&quot;&gt;Continue reading &lt;span class=&quot;meta-nav&quot;&gt;→&lt;/span&gt;&lt;/a&gt;&lt;img src=&quot;http://stats.wordpress.com/b.gif?host=jeremykun.wordpress.com&amp;amp;blog=23934684&amp;amp;post=1569&amp;amp;subd=jeremykun&amp;amp;ref=&amp;amp;feed=1&quot; alt=&quot;&quot; height=&quot;1&quot; border=&quot;0&quot; width=&quot;1&quot; /&gt;</content>
		<author>
			<name>j2kun</name>
			<uri>http://jeremykun.wordpress.com</uri>
		</author>
	</entry>

	<entry>
		<title>Programming Praxis: Knights On A Keypad</title>
		<link rel="alternate" type="text/html" href="http://programmingpraxis.com/2012/01/20/knights-on-a-keypad/"/>
		<id>http://programmingpraxis.com/?p=5313</id>
		<updated>2012-01-20T09:00:18+00:00</updated>
		<content type="html">&lt;p&gt;Today’s exercise is an interview question that &lt;a href=&quot;http://stackoverflow.com/questions/2893470/generate-10-digit-number-using-a-phone-keypad&quot;&gt;appeared&lt;/a&gt; on Stack Overflow a few years ago:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;The numbers on a telephone keypad are arranged thus:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;1 2 3&lt;br /&gt;
4 5 6&lt;br /&gt;
7 8 9&lt;br /&gt;
  0&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Starting from the digit 1, and choosing successive digits as a knight moves in chess, determine how many different paths can be formed of length &lt;em&gt;n&lt;/em&gt;. There is no need to make a list of the paths, only to count them.&lt;/p&gt;
&lt;p&gt;A knight moves two steps either horizontally or vertically followed by one step in the perpendicular direction; thus, from the digit 1 on the keypad a knight can move to digits 6 or 8, and from the digit 4 on the keypad a knight can move to digits 3, 9 or 0. A path may visit the same digit more than once.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Your task is to write a function that determines the number of paths of length &lt;em&gt;n&lt;/em&gt; that a knight can trace on a keyboard starting from digit 1. When you are finished, you are welcome to &lt;a href=&quot;http://programmingpraxis.com/2012/01/20/knights-on-a-keypad/2/&quot;&gt;read&lt;/a&gt; or &lt;a href=&quot;http://programmingpraxis.codepad.org/k8lxMxUC&quot;&gt;run&lt;/a&gt; a suggested solution, or to post your own solution or discuss the exercise in the comments below.&lt;/p&gt;
&lt;br /&gt;  &lt;a href=&quot;http://feeds.wordpress.com/1.0/gocomments/programmingpraxis.wordpress.com/5313/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/comments/programmingpraxis.wordpress.com/5313/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godelicious/programmingpraxis.wordpress.com/5313/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/delicious/programmingpraxis.wordpress.com/5313/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gofacebook/programmingpraxis.wordpress.com/5313/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/facebook/programmingpraxis.wordpress.com/5313/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gotwitter/programmingpraxis.wordpress.com/5313/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/twitter/programmingpraxis.wordpress.com/5313/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/gostumble/programmingpraxis.wordpress.com/5313/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/stumble/programmingpraxis.wordpress.com/5313/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/godigg/programmingpraxis.wordpress.com/5313/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/digg/programmingpraxis.wordpress.com/5313/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://feeds.wordpress.com/1.0/goreddit/programmingpraxis.wordpress.com/5313/&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://feeds.wordpress.com/1.0/reddit/programmingpraxis.wordpress.com/5313/&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;img src=&quot;http://stats.wordpress.com/b.gif?host=programmingpraxis.com&amp;amp;blog=6649073&amp;amp;post=5313&amp;amp;subd=programmingpraxis&amp;amp;ref=&amp;amp;feed=1&quot; alt=&quot;&quot; height=&quot;1&quot; border=&quot;0&quot; width=&quot;1&quot; /&gt;</content>
		<author>
			<name>programmingpraxis</name>
			<uri>http://programmingpraxis.com</uri>
		</author>
	</entry>

	<entry>
		<title>Joe Marshall: A bit more challenging</title>
		<link rel="alternate" type="text/html" href="http://funcall.blogspot.com/2012/01/bit-more-challenging.html"/>
		<id>tag:blogger.com,1999:blog-8288194986820249216.post-8550473143881422377</id>
		<updated>2012-01-19T17:11:27+00:00</updated>
		<content type="html">In my &lt;a href=&quot;http://funcall.blogspot.com/2012/01/slightly-trickier.html&quot;&gt;previous post&lt;/a&gt;, I gave the puzzle of taking a pattern and generating code that matches it.  The tricky part was making sure that the pattern is completely traversed at compile time.  If the object to be tested matches the pattern, the pattern variables and their values were to be returned in an alist.&lt;br /&gt;
&lt;br /&gt;
It would be better, however, to generate code where the pattern variables become &lt;em&gt;bindings&lt;/em&gt; of Scheme variables.  Instead of generating code that stuffs the values into an alist, like this code does at the highlighted points:
&lt;br /&gt;
&lt;pre&gt;(make-matcher '(&lt;span style=&quot;background-color: lime;&quot;&gt;(? one)&lt;/span&gt; and &lt;span style=&quot;background-color: lime;&quot;&gt;(? two)&lt;/span&gt;)) =&amp;gt;

(lambda (object)
  (and (pair? object)
       (let ((left-submatch
              ((lambda (object) &lt;span style=&quot;background-color: lime;&quot;&gt;(list (cons 'one object))&lt;/span&gt;) (car object)))
             (right-submatch
              ((lambda (object)
                 (and (pair? object)
                      (let ((left-submatch
                             ((lambda (object)
                                (and (eqv? object 'and)
                                     '()))
                              (car object)))
                            (right-submatch
                             ((lambda (object)
                                (and (pair? object)
                                     (let ((left-submatch
                                            ((lambda (object)
                                               &lt;span style=&quot;background-color: lime;&quot;&gt;(list (cons 'two object))&lt;/span&gt;)
                                             (car object)))
                                           (right-submatch
                                            ((lambda (object)
                                               (and (eqv? object '())
                                                    '()))
                                             (cdr object))))
                                       (and left-submatch
                                            right-submatch
                                            (append left-submatch
                                                    right-submatch)))))
                              (cdr object))))
                        (and left-submatch
                             right-submatch
                             (append left-submatch right-submatch)))))
               (cdr object))))
         (and left-submatch
              right-submatch
              (append left-submatch right-submatch)))))&lt;/pre&gt;
We'd generate something more like this:
&lt;br /&gt;
&lt;pre&gt;(make-matcher '(&lt;span style=&quot;background-color: lime;&quot;&gt;(? one)&lt;/span&gt; and &lt;span style=&quot;background-color: lime;&quot;&gt;(? two)&lt;/span&gt;) &lt;i&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;&amp;lt;user code goes here&amp;gt;&lt;/span&gt;&lt;/i&gt;) =&amp;gt;

(lambda (object)
  (and (pair? object)
       (let (&lt;span style=&quot;background-color: lime;&quot;&gt;(one (car object)&lt;/span&gt;)
             (tail1 (cdr object)))
         (and (pair? tail1)
              (eq? (car tail1) 'and)
              (let ((tail2 (cdr tail1)))
                (and (pair? tail2)
                     (let (&lt;span style=&quot;background-color: lime;&quot;&gt;(two (car tail2)&lt;/span&gt;))
                       (and (null? (cdr tail2))
                            &lt;span style=&quot;background-color: yellow;&quot;&gt;&lt;i&gt;&amp;lt;user code goes here&amp;gt;&lt;/i&gt;&lt;/span&gt;))))))))
&lt;/pre&gt;
This is more challenging for two reasons.  First, we need to ensure that the pattern variable names become bound in a scope that encloses the user's code so that free references to pattern variables are correctly captured.  In addition, we need to ensure that other “helper” bindings, like &lt;code&gt;tail1&lt;/code&gt; and &lt;code&gt;tail2&lt;/code&gt; do &lt;em&gt;not&lt;/em&gt; capture free references by accident. (That is to say, watch your macro hygiene.)  Second, you have to be sure that subpattern bindings are visible to the entire body of the user code.  This will throw a monkey wrench into the simple recursive solution.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/tracker/8288194986820249216-8550473143881422377?l=funcall.blogspot.com&quot; alt=&quot;&quot; height=&quot;1&quot; width=&quot;1&quot; /&gt;&lt;/div&gt;</content>
		<author>
			<name>Jrm (noreply@blogger.com)</name>
			<uri>http://funcall.blogspot.com/</uri>
		</author>
	</entry>

</feed>

