Sunday, February 16, 2025

12. Write a Prolog program to implement reverse(List,ReversedList) that reverses lists.

 

Write a Prolog program to implement reverse(List,ReversedList) that reverses lists.

% Write a Prolog program to implement reverse(List,ReversedList) that reverses
% lists.


/* Reverse of the list. */

reverse([H|T],R):-
 length(T,L),
 L>0 ->
 (
  reverse(T,R1),
  /* write(R1), */
  R is H
 )
 ;
 R is H.
% Output
Prolog program to implement reverse(List,ReversedList) that reverses lists.
Prolog Program to reverse the elements in the list.

1 comment:

  1. Marketing assignments often require research, strategic thinking, market analysis, and clear presentation of ideas. Students can benefit from guidance when working on topics such as consumer behavior, digital marketing, branding, and promotional strategies. Professional marketing assignment help can provide useful academic support, explanations, and research guidance while helping students improve their understanding of key concepts. Choosing a reliable service can make complex coursework more manageable and help students develop stronger analytical, research, and communication skills.

    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 ...