Subject: Re: realistic but short and simple LISP examples?
From: Erik Naggum <erik@naggum.net>
Date: Sun, 16 Dec 2001 05:29:25 GMT
Newsgroups: comp.lang.lisp
Message-ID: <3217469363108222@naggum.net>

* Wroot <wroot@my-deja.com>
| Here's one (challenge to LISP programmers)

  Have you considered downgrading your arrogance to a reasonable level?

  Here is a challenge for you.  Write a function that accepts an expression
  and a list of values for the variables and returns the lambda expression
  applied to these values.  (To reduce the complexity of the task when
  accepting an expression from the user, you may assume that a compiler is
  available in the function compile, so this is _not_ about making an
  evaluator.)  Call the function you write apply.

  For extra bonus points, write an evaluator using the apply function you
  just wrote, which evaluates all arguments of an expression before calling
  the function with the values collected from that evaluation.  Call this
  function eval.

  For even more extra bonusp points, write a function read that accepts a
  character stream and returns the next expression the user has supplied on
  that stream.  Match it with a function write that accepts an object of
  any kind and produces a character stream suitable for read and humans.

  If you have time, write a simple loop which calls read to obtain an
  expression from the user, then calls eval to obtain the result of
  evaluating it, and finally calls write to show the user this result.

  If you complete all this, you have what every Common Lisp programmer gets
  for free when he starts up his Common Lisp system.  Please think through
  the challenge before you dismiss any of this as trivial.  Basically, a
  major part of the Lisp language follows from the decision to make this
  interactive loop work correctly.  Note that in Common Lisp these
  functions are available from the get go with the names I have suggested.

  If you still think you have any business coming here with "challenges",
  please consider your own reaction to an ignorant splut who came up to you
  and "challenged" you do to something he had just learned.  _I_ find it on
  par with a stupid kid who has just learned a bad word and tries to get
  adults to say it so he can snicker.

///
-- 
  The past is not more important than the future, despite what your culture
  has taught you.  Your future observations, conclusions, and beliefs are
  more important to you than those in your past ever will be.  The world is
  changing so fast the balance between the past and the future has shifted.