IDEA: LISP Interpreter

This is a discussion on IDEA: LISP Interpreter within the Contests Board forums, part of the Community Boards category; i've written a tutorial on lisp for the uninformed. http://www.flashdaddee.com/Tutorials/yfperson.html it's a fairly simple scripting language. here's an example: code: ...

  1. #1
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493

    IDEA: LISP Interpreter

    i've written a tutorial on lisp for the uninformed.
    http://www.flashdaddee.com/Tutorials/yfperson.html
    it's a fairly simple scripting language. here's an example:

    code:
    (defun func1 (x)
    (- x 4)
    (+ x 3) )
    (func1 (- (+ 3 5) (/ 3 7)))


    3 + 5 = 8, 3 / 7 = 3/7
    8 - 3/7 = 7 4/7
    func1 is a user-defined function which adds 3 to whatever x is. the value returned is 10 4/7 (or whatever that is in decimal).
    the last statement in a user-defined function is the value that is returned. func1 ignores (- x 4) because it doesn't really do anything.

    lisp is named lisp because of its list variables and built in lisp manipulation functions. because implementing that would take too much time, list manipulation is not required.

    here is what's required in the lisp interpreter (if voted for):

    • it needs to work with nested lisp expressions, where a single expression is bounded by two parentheses. each expression returns some value
    • you need to create some predefined functions like +, -, *, /, etc...
      you know, the simple stuff.
    • each program needs to be able to define functions like i showed above (using the defun statement). hint: unlike C functions, which does type-checking and other complicated stuff, the defun command should be more like the C #define command.
      so, in other words:
      Code:
      (defun func1 (x) (+ x 3))
      (func1 7)
      this should become:
      Code:
      (+ 7 3)
      which is easy to evaluate.
    • each program should check the number of parentheses to help make sure there aren't any typos. this could be as simple as counting the number of '(', then counting the number of ')', and seeing if the numbers match

    one last thing, not LISP-related:
    if the search/replace program is voted for, you cannot use the string classes with it. that would just be too easy

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    cshot seconds

  3. #3
    Nick
    Guest
    If your intrested in lisp like languages one cool book I've found is
    http://mitpress.mit.edu/sicp/full-text/book/book.html
    I havn't had enough time to read the whole thing (or halve)
    though (:

  4. #4
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    cshot seconds
    I won't be able to participate now as summer is now ending and I will be very busy

    However I'd still like to see people tackle this.
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  5. #5
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    bump

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Have an idea?
    By B0bDole in forum Projects and Job Recruitment
    Replies: 46
    Last Post: 01-13-2005, 02:25 PM
  2. A little problem about an idea, help please
    By louis_mine in forum C++ Programming
    Replies: 3
    Last Post: 09-10-2004, 09:52 PM
  3. Terrain engine idea
    By VirtualAce in forum Game Programming
    Replies: 15
    Last Post: 04-03-2004, 12:30 AM
  4. totally screwed up idea
    By iain in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 08-17-2001, 12:09 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21