Introduction

LISP

LISP Programs

Expert Systems

LISP Programs

  1. To sum all the even elements of the list
  2. Sum all the elements upto n
  3. Sum of squares of all the elements in the list
  4. Count the number of elements in a list
  5. Sum all the elements upto n using iteration
  6. To return the Nth element of the list
  7. Write a LISP program addlist that takes as its arguments an element and a list.If the element is already in the list,the function returns the input list;otherwise it returns the list that includes the given element in the original list.

Example : (addlist 'c '(a,b,c,d)) = (a,b,c,d)

(addlist 'e '(a,b,c)) = (e,a,b,c)

  1. Write a LISP program which reads five numbers,calculates their sum and the Nth power of individual numbers.The results must be stored in 2 separate lists.
  2. Factorial - Recursion
  3. Factorial - Iterative
  4. Write a LISP function max3 which finds maximum of 3 numbers.
  5. Define the functions called left-rotate and right-rotate,these 2 functions takes a list and rotates the elements by one position as in

right-rotate '(a b c d) returns (d a b c)

left-rotate '(a b c d) returns(b c d a)

 

 Ó CodeEverywhere