You are on page 1of 1

Program: enter two matrices and calculate the max from both of them

max1([H],N):-N is H.

max1([H|T],N):-max1(T,K),H>K,N is H.

max1([H|T],N):-max1(T,K),H<K,N is K.

max1([H|T],N):-max1(T,K),H=K,N is H.

supmax1([H|T],[H1|T1]):- max1([H|T], M1), max1([H1|T1], N1), M1>N1,write(M1).

supmax1(L1,L2):- max1(L1, M1), max1(L2, N1), M1=< N1,write(N1).

calculate max no in lisp on runtime

(defun max1(q n) (setq r(read))(if (> r q)(setq q r))

(if (= n 1)

(write q)

(max1 q (- n 1)))

You might also like