------_extPart_001_01C5CA05.F67C280A
Content-Type: text/plain;
	charsets-ascii"
Content-Transfer-Encoding: quoted-printable

I'm always sending the wrong files.

This is the bit that actually implements the quiz (ie. lets you play the
game), as opposed to the last one which just played with itself and made
sure it got the right output.

-----Original Message-----
From: Daniel Sheppard 
Sent: Wednesday, 5 October 2005 6:23 PM
To: ruby-talk ML
Subject: [SOLUTION] Lisp Game (#49)

  
This was an interesting one.

I started out trying to do a fairly word-for-word translation to ruby,
and then started on a loose translation after I hit the defmacro stuff. 

Then I thought, screw that. Why not parse LISP? I think ended up getting
a much better understanding of all the bits that the casting SPELS
article glossed over. 

Herein, an extremely inelegant, and potentially severely broken lisp
processor.

It allows you to write code like the following:

require 'lisp'
class Monkey
  include Lisp
  include Lisp::StandardFunctions
  def boogers
    "Monkeys!!"
  end
end

x = Monkey.new
x.lisp "(setf *something* 'value)"
x.lisp "(defun saysomething () *something*)"

x.saysomething()
=> "value"
x.lisp "(saysomething)"
=> "value"
x.lisp "(boogers)"
=> "Monkeys!!"


########################################################################
#############
This email has been scanned by MailMarshal, an email content filter.
########################################################################
#############



#####################################################################################
This email has been scanned by MailMarshal, an email content filter.
#####################################################################################

------_extPart_001_01C5CA05.F67C280A
Content-Type: application/octet-stream;
	nameuiz_49b_lisp.rb"
Content-Transfer-Encoding: base64
Content-Description: quiz_49b_lisp.rb
Content-Disposition: attachment;
	filenameuiz_49b_lisp.rb"

cmVxdWlyZSAnbGlzcCcNCg0KbGlzcCA9IE9iamVjdC5uZXcNCmxpc3AuZXh0ZW5kKExpc3ApDQps
aXNwLmV4dGVuZChMaXNwOjpTdGFuZGFyZEZ1bmN0aW9ucykNCg0KbGlzcC5saXNwKDw8LUVPRikN
CihkZWZwYXJhbWV0ZXIgdHBsOipwcmludC1sZW5ndGgqIG5pbCkNCg0KKGRlZnBhcmFtZXRlciAq
b2JqZWN0cyogJyh3aGlza2V5LWJvdHRsZSBidWNrZXQgZnJvZyBjaGFpbikpDQoNCihkZWZwYXJh
bW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