#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    33
    Rep Power
    6

    Reading from a list - LISP


    Hi all,

    I'm trying to retrieve all of the games from a list of games in LISP but am having trouble writing the function.

    Here is the code:
    Code:
    (setf games '(
    	((title "Doom")
    	(genre "FPS")
    	(platform "PC")
    	(players "Singleplayer")
    	(price 4.99))
    	
    	((title "Quake")
    	(genre "FPS")
    	(platform "PC")
    	(players "Singleplayer")
    	(price 4.99))
    
            ; And so on...
    ))
    And I wish to retrieve the details of 1 game. I tried the following code:
    Code:
    (defun retrieve-game (title)
    	(assoc 'title games))
    And if I type (retrieve-game "Doom") I get NIL.

    I am very confused, can anyone help me?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    33
    Rep Power
    6
    Don't all rush at once to respond!

    It's okay anyways guys, I worked it out!

IMN logo majestic logo threadwatch logo seochat tools logo