From ... Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!194.25.134.62!newsfeed00.sul.t-online.de!t-online.de!diablo.theplanet.net!newsfeed.esat.net!nslave.kpnqwest.net!nloc.kpnqwest.net!nmaster.kpnqwest.net!nreader3.kpnqwest.net.POSTED!not-for-mail Newsgroups: comp.lang.lisp Subject: Re: realistic but short and simple LISP examples? References: <9vgtl8$6un$1@newsmaster.cc.columbia.edu> Mail-Copies-To: never From: Erik Naggum Message-ID: <3217469363108222@naggum.net> Organization: Naggum Software, Oslo, Norway Lines: 45 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 16 Dec 2001 05:29:25 GMT X-Complaints-To: newsmaster@KPNQwest.no X-Trace: nreader3.kpnqwest.net 1008480565 193.71.66.49 (Sun, 16 Dec 2001 06:29:25 MET) NNTP-Posting-Date: Sun, 16 Dec 2001 06:29:25 MET Xref: archiver1.google.com comp.lang.lisp:22509 * Wroot | 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.