0% found this document useful (0 votes)
7K views1 page

Maximum of Two and Three Numbers in Lisp

This document contains Lisp code definitions for functions to find the maximum of two or three values and check if three values form a triangle. It defines an ifmax function to return the maximum of two values, an ifmax3 function to return the maximum of three values, and a triangle function that uses a check function to return whether three values form a triangle.

Uploaded by

Sirak Tefahun
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, TXT or read online on Scribd
0% found this document useful (0 votes)
7K views1 page

Maximum of Two and Three Numbers in Lisp

This document contains Lisp code definitions for functions to find the maximum of two or three values and check if three values form a triangle. It defines an ifmax function to return the maximum of two values, an ifmax3 function to return the maximum of three values, and a triangle function that uses a check function to return whether three values form a triangle.

Uploaded by

Sirak Tefahun
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, TXT or read online on Scribd
You are on page 1/ 1

maximum two

(defun ifmax(a b)(if (> a b) a (if(> b a) b 'equal)))

maximum three

(defun ifmax3(a b c) (if (and(> a b)(> a c)) a (if(and(> b a)(> b c)) b (if(and(>
c a)(> c b)) c 'equal))))

(defun ifmax3(a b c) (if (and(> a b)(> a c)) (if(and(> b a)(> b c)) b (if(and(> c
a)(> c b)) c 'equal))))

triangle

>(defun check(x y z) (if (> (+ y z) x) "triangle" "not triangle"))

CHECK

>(defun triangle (a b c) (if (and (> a b)(> b c)) (check a b c) (if (and (> b a)
(> a c)) (check b a c) (check c a b))))

You might also like