Sunday, February 16, 2025

9. Write a Prolog program to implement maxlist(List,Max) so that Max is the greatest number in the list of numbers List.

 

Write a Prolog program to implement maxlist(List,Max) so that Max is the greatest number in the list of numbers List.

% Write a Prolog program to implement maxlist(List,Max) so that Max is the 
% greatest number in the list of numbers List.


/* Max of n-#.s in a list. */
maxlist([H|T],R):-
 length(T,L),
 L>0 ->
 (
  maxlist(T,R1),
  (
   H > R1 -> 
     R is H
    ;
     R is R1
  )
 ) 
 ;
 R is H.
% Output
Prolog program to implement maxlist(List,Max) so that Max is the greatest number in the list of numbers List.
Prolog Program to find maximum number in the list of N numbers.

1 comment:

  1. This article provides useful information for students studying finance and related subjects. Complex calculations, financial analysis, and theoretical concepts can make assignments challenging to complete independently. Having access to appropriate academic guidance can make the learning process easier. I recently explored finance assignment helper services that provide structured assistance and subject-related guidance. This can help learners understand difficult concepts, organise their assignments effectively, and work towards better academic performance.

    ReplyDelete

15. Write a Prolog program to implement two predicates evenlength(List) and oddlength(List) so that they are true if their argument is a list of even or odd length respectively.

  Write a Prolog program to implement two predicates evenlength(List) and oddlength(List) so that they are true if their argument is a list ...