728x90 AdSpace

Latest Article



LISP Expressions Exercise Question MCQ's





LISP Expressions Exercise lab Question try this expression and solve it.
Execute the following commands and write the answers below each expression.

1> 10   2> 123.23        3> “hello world”                     4> x    

5> (quote   x)              6> ‘x                            7> hello              8> ‘hello

9> (+   10     5)            10>  (*      2       3     4)           11> (-    10      5     3)    12>  (/    8     2    2)

13>  (print    “hello”)   14> (setq    x    10)                 15> (setq    y     5)                   16>  (print   x)   

17> (+    x     y)           18> (+   ( *    2    3)  (+   1   1)     (1+      3)     )

19> (+    (+   2    x)   (/    x      (/   4   2))  (+     (/    (1-    y)  2)    x)      ) 

20> ( car     ‘(a    b    c))                21> (car    ‘( (a  b)  ( b     c))  )                 

22>  (car   ‘( c )  )                    23> (car   ‘(((a  b  c)))   )              

24> (car    ‘((((a    b   c)  d )   e))  )                                25> (car   ‘(a   ((b   c )))  )

26> (car  ‘((a   b   c)  (d   e))                            27> (car   ‘((a   b)  (c   d)  (e   f))  )

28>(car  ‘((a   b  c  d))  )                                  29> ( cdr     ‘(a    b    c))         

30> (cdr    ‘( (a  b)  ( b     c))  )                        31>  (cdr   ‘( c )  )                   

32> (cdr   ‘(((a  b  c)))   )                                 33> (cdr    ‘((((a    b   c)  d )   e))  )

34> (cdr   ‘(a   ((b   c )))  )                               35> (cdr  ‘((a   b   c)  (d   e)) 

36> (cdr   ‘((a   b)  (c   d)  (e   f))  )                 37>(cdr  ‘((a   b  c  d))  )


Execute the following lisp expressions in given sequence?

1> ( member     ‘c    ‘(  A    B      C     D ))           2> ( member     ‘c    ‘(  A    (b      c)     D ))

3> (member   ‘(a)    ‘(a   b  c)     )                                4> (member   ‘(b)    ‘(a  ( b)  c)    )                

5> (member   ‘(b)    ‘(a  ( b ) c e)     :test  ‘equal)                    6> ( >    4    2)                                  

7> (<    4    2 )                         8> (string>     ‘B      ‘C)          9>  (string<    “AB”   “ABC” )     

10> (string-equal  ‘abc  ‘ABC)                       11> (or   (evenp  3 )   (atom  ‘( a ))  ) 

12> (and   (evenp   4 )    (atom     “abc” )       (consp        ‘(a  b))   )

13> (or   (not   (evenp  4 ))   (atom    ‘(a ) )     4    (listp   ‘a)  )

14>   (and   (null    nil )   (or     (zerop   3 )    nil      t )    (consp   nil )    (print  (setq    x     3 ))    )

15> x     16>  (and  (null  nil )  (or   (zerop  3)  nil  t ) (consp   ‘(nil) )  (print  (setq     x     3 ) )   )


17> x   18> (if    x    “x”     “ nothing” )          19>  (if   ‘x     “yes”     “no” )        

20> (if   (evenp  3 )   (print   “even”) )            21>(if   (oddp   3 )  (+    10    3 )   (-    3   1 ) )     

22>  (if     (setq   y    10 )   (+     y     y )   (-    y     y)  )         

23>( if  (+    y     y)   (/    y    2 )   (*    y   2 ) )          24> (if    (not  “a bc” )    “no”   “yes” )

25> (cond   ( (oddp    4)   (+   3   4 ))             26> (cond  ((evenp  3)  (print  “even” )  (+    3   4 ))
                    (4    (+  3  10))      )                                       ((oddp  4)   (print  “4” )  (+    4   46 ))
                                                                                             (t    (print    “nothing” )  0 )      )  

27> (setq  z   24 ) 
28> (cond    ((not   (atom z ))   (print  “list” )  (if   (functionp   (car   z ))  “form”   “constant” )  )
                    ((atom   z)   (cond   ((symbolp    z )    “symbol” ) 
                                                    ((numberp   z)     (cond    ((evenp   z )   “even”)
                                                                                          ((oddp  z )      “odd” )  )  )    ) )    
                (t   “nothing” ) )


no image
  • Title : LISP Expressions Exercise Question MCQ's
  • Posted by :
  • Date : 10:37
  • Labels :






  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment