×
Aiming for the stars? Great, but did you have to build a rocket first.
--Your friends at LectureNotes
Close

Note for Principles of Programming Languages - ppl By Shivansh Singh

  • Principles of Programming Languages - ppl
  • Note
  • 414 Views
  • 6 Offline Downloads
  • Uploaded 6 months ago
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

PROGRAM-1 Define a LISP function to compute sum of squares. >(defun sum_of_sqr(x y) (+(* x x)(* y y))) OUTPUT

Text from page-2

PROGRAM-2 Define a LISP function to compute the difference of squares. (if x>y return x2-y2, otherwise y2-x2) >(defun diff_of_sqr(x y) (if(> x y) (-(* x x)(* y y)) (-(* y y)(* x x)))) OUTPUT

Text from page-3

PROGRAM-3 Define a recursive LISP function to solve Ackermann’s function. >(defun ackermann(x y) (cond ((= x 0) (+ y 1)) ((= x 1) (+ y 2)) ((= x 3) (+ 3 (* y 2))) ((= x 3) (+ 5 (* 8(-(expt 2 y) 1)))) (t (cond ((= y 0) (ackermann (- x 1) 1)) (t (ackermann(- x 1) (ackermann x (- y 1)))) )) )) OUTPUT

Text from page-4

PROGRAM-4 Define a recursive LISP function to compute factorial of a given number. >(defun factorial(n) (if (= n 1) 1 (* n (factorial(- n 1))))) OUTPUT

Lecture Notes