Where do I post my questions related to LISP programming???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lifeisgreat20009
    New Member
    • Oct 2007
    • 70

    Where do I post my questions related to LISP programming???

    I didnt find any forum for that so I am posting here......

    The problem is that I want to make a menu driven program in LISP.......

    I have written all the functions that will be there in the menu options but I do not know how to implement a case statement in LISP........
    I searched a lot for this on net but in vain..........

    My guess is that the program should look like this.......

    Code:
    defun  function1 ( parameters ...)
      (
    .
    .
    .
        )
    
    
    defun  function2 ( parameters ...)
      (
    .
    .
    .
        )
    
    
    defun  function3 ( parameters ...)
      (
    .
    .
    .
        )
    
    
    case
    
    1: function1
    
    2: function2

    and so on.......


    plz somebody tell me how do I implement this case statement...... ....
  • Stang02GT
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    Unfortunately i don't know anything about LISP but i commend you for looking around first and not just posting this question anywhere. Thank you!

    Comment

    • lifeisgreat20009
      New Member
      • Oct 2007
      • 70

      #3
      Originally posted by Stang02GT
      Unfortunately i don't know anything about LISP but i commend you for looking around first and not just posting this question anywhere. Thank you!

      I have made another version of my program using cond statement which is as follows. The problem is that it is returning nil as the answer every time......

      please somebody tell me why is it not working ???


      Code:
      (defun  reverse-list-aux  (l  x)
         (if  (null  l)
                x
            (reverse-list-aux  (cdr  l)  (cons  (car  l)  x))))
      
      
      ;***********************************************************************
      
      (defun raise-aux (result number-list)
      (if (endp number-list)
      result
      (raise-aux (expt result (first number-list))
      (rest number-list))))
      (defun raise (x &rest numbers)
      (raise-aux x numbers))
      
      ;***********************************************************************
      
      (defun sum-list (list)
                  (if list
                      (+ (car list) (sum-list (cdr list)))
                    0))
      
      
      ;***********************************************************************
      (defun rotate-left (l)
      (append (cdr l) (list (car l))))
      
      
      
      
      
      ;***********************************************************************
      
      (defun rotate-right (l)
      (append (last l) (list (butlast l))))
      
      
      ;***********************************************************************
      
      
      (setq p 1)
      
      (defun
       mymenu (p)
      
      (cond 
      
      ((equal p 1)
      (reverse-list-aux '(a b c d e f g h) () )
      
      ((equal p 2)
      (raise '(2 3 5))
      
      ((equal p 3)
      (sum-list '(2 3))
      
      ((equal p 4)
      (rotate-left '(a b c))
      
      ((equal p 5)
      (rotate-right '(a b c))
      
      (t 'Sorry you can only give 1,2,3,4 as arguments))))))))
      
      (mymenu '3)

      Comment

      • lifeisgreat20009
        New Member
        • Oct 2007
        • 70

        #4
        I have made the above program using cond statement . The problem is that it is returning nil as the answer every time......

        please somebody tell me why is it not working ???


        NOTE: All the functions defined in the above program are working well when run separately

        i wanted to make this program using case statement but I dont know how to implement that. A searched a lot about case statement but in vain. plz help if anyone knows that.

        Comment

        • lifeisgreat20009
          New Member
          • Oct 2007
          • 70

          #5
          Is there nobody who can help me with LISP artificial intelligent language ?????

          Comment

          • peterlane
            New Member
            • Apr 2008
            • 1

            #6
            The problem with your code is that you haven't matched the brackets -- see the comment below. You have to follow the pattern:

            (cond (test result) (test result) (else result))

            Originally posted by lifeisgreat2000 9
            I have made another version of my program using cond statement which is as follows. The problem is that it is returning nil as the answer every time......

            please somebody tell me why is it not working ???


            Code:
            (cond 
            
            ((equal p 1)
            (reverse-list-aux '(a b c d e f g h) () )
            ) ; match the one before ((equal ...
            ((equal p 2)
            (raise '(2 3 5))
            )  ; match the one before ((equal ...
            For your previous question, there is a case statement in Lisp:
            Code:
            (defun menu (p) (case p ((1) 'one) ((2) 'two) ((3) 'three)))
            See Paul Graham's ANSI Common Lisp or Peter Seibel's http://gigamonkeys.com/book/ for more information on Lisp.

            Comment

            • lifeisgreat20009
              New Member
              • Oct 2007
              • 70

              #7
              Originally posted by peterlane
              The problem with your code is that you haven't matched the brackets -- see the comment below. You have to follow the pattern:

              (cond (test result) (test result) (else result))



              For your previous question, there is a case statement in Lisp:
              Code:
              (defun menu (p) (case p ((1) 'one) ((2) 'two) ((3) 'three)))
              See Paul Graham's ANSI Common Lisp or Peter Seibel's http://gigamonkeys.com/book/ for more information on Lisp.



              Hey thanks so much .....
              I tried the prog using case statement and its working fine except for the raise function....
              I have run this program separately and its working fine but somehow its not working in this case menu driven program...

              Its giving the following error..


              CL-USER 6 > (menu 2)

              Error: Undefined operator X in form (X NUMBERS).
              1 (continue) Try invoking X again.
              2 Return some values from the form (X NUMBERS).
              3 Try invoking something other than X with the same arguments.
              4 Set the symbol-function of X to another function.
              5 Set the macro-function of X to another function.
              6 (abort) Return to level 0.
              7 Return to top loop level 0.

              Type :b for backtrace, :c <option number> to proceed, or :? for other options


              Plzzz help me..........
              thanks......... ...........

              Comment

              Working...