Sunday, February 16, 2025

6. Write a Prolog program to remove the Nth item from a list.

 

Write a Prolog program to remove the Nth item from a list.

% Write a Prolog program to remove the Nth item from a list.

/*delete a number in the list. */
delte(1,[_|T],T).
delte(P,[X|Y],[X|R]):-
 P1 is P-1,
 delte(P1,Y,R).
% Output
Prolog program to remove the Nth item from a list
                        Prolog program to remove the Nth item from a list

No comments:

Post a Comment

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