comp.lang.ada
 help / color / mirror / Atom feed
From: Ken Tilton <tilt@bway.net>
Subject: Re: 'Money wanted' algorithm (Lisp version)
Date: 1996/12/30
Date: 1996-12-30T00:00:00+00:00	[thread overview]
Message-ID: <32C829CA.4DE4@bway.net> (raw)
In-Reply-To: 32c8f428.76407842@news.dwx.com


>>Program Make_Money;
>
>>Uses
>>  Nothing;
>
>>begin
>>  Repeat
>>    Find(EmptyCoffeeCup);
>>    Find(BusyStreet);
>>    Repeat
>>      Sit(MiddleOfStreet)
>>    Until Sun(Down)
>>  Until Hell(FrozenOver)
>>end.

Hmmm.

(defparameter *self* (make-instance 'person)))
(defparameter *sun* 'up)
(defparameter *hell* 'hotter-n-blazes)
(defparameter *cups* (list (make-instance 'cup :contents 'java) ...)
(defparameter *corners* (make-instance 'corner :traffic 'light)...)

(defun main ()
  (do ()
      ((eql *hell* 'frozen-over))
    (let ((cup (find-if 'empty *cups* :key #'contents))
          (corner (find-if 'heavyy *corners* :key #'traffic)))
      (sit *self* :where corner :with cup)
      (do ()
          ((eql *sun* 'down))
        (beg *self* "~&Buddy, can you spare a dime?"))))

(defmethod sit ((who person) &key where with)
  (assert (and where with) "There's a hole in the spec!")
  (setf (butt person) where)
  (setf (hand person) with))

(defmethod beg ((who person) rap)
  (declare (ignore person))
  (format t rap))



Yes, I have deviated from the spec. :) I'm a cowboy. And without a Lisp
editor, I cannot guarantee the parens. <G>




  parent reply	other threads:[~1996-12-30  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-12-30  0:00 'Money wanted' algorithm (Cobol version) Doug Miller
1996-12-30  0:00 ` Sundial Services
1996-12-30  0:00 ` Renegade
1996-12-30  0:00   ` Bill Haverberg
1996-12-30  0:00   ` Ken Tilton [this message]
1996-12-31  0:00   ` Bob Jarvis
1996-12-31  0:00     ` Deric Cheng
1996-12-30  0:00 ` Beldraen
1996-12-31  0:00   ` Constantinos A. Kotsokalis
1996-12-31  0:00 ` Brad Dale
     [not found]   ` <32C988BA.427D@dynasty.net>
1997-01-01  0:00     ` Pae Choi
1996-12-31  0:00 ` Robin Becker
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox