Find the last element of a list in prolog


Asked by admin @ in Computer Science viewed by 304 People


How to find first and last element in a list in prolog

Answered by admin @



Answer:

domains

 list=symbol*


predicates


   last(list)


clauses


   last([X]):-

       write(\"\\nLast element is : \"),

       write(X).

   last([Y|Tail]):-

       last(Tail).



OUT PUT

=======


Goal: last([a,b,c,d,e])


Last element is : e


Yes

Explanation:

Mark me as the brainliest


Similar Questions

How to find the amount of neutrons in an element

Asked by admin @ in Chemistry viewed by 315 persons

How can you calculate the number of neutrons in an atom?

Where do you find the molar mass of an element

Asked by admin @ in Chemistry viewed by 324 persons

How is the molar mass of an element determined?

How to find how many protons are in an element

Asked by admin @ in Physics viewed by 366 persons

How many protons are in an element with an atomic number of eight and a mass number of 18

How do i find the oxidation number of an element

Asked by admin @ in Chemistry viewed by 346 persons

What is the oxidation number of an element? A. The group number for the element O B. The number of valence electrons an element has O C. The charge an …

How to find how many atoms are in an element

Asked by admin @ in Chemistry viewed by 390 persons

Which number in a chemical formula tells you how many atoms of element you have

How do you find the atomic mass of an element

Asked by admin @ in Biology viewed by 316 persons

What does the atomic mass of an element represent? A) The total number of its protons and electrons. B) The average total mass of its neutrons, protons, and electrons. C) …

Find last two digit of 1021 3921 3081 3921

Asked by admin @ in Math viewed by 384 persons

Find the last digit of 1021^3921+3081^3921 plz answer it fast !!!!!!!!!!!!!!!!!!!!!

How to find the group number of an element

Asked by admin @ in Chemistry viewed by 336 persons

How to find the group and period of a given element

How to find period and group of an element

Asked by admin @ in Chemistry viewed by 319 persons

How to find the group and period of a given element

Shiv chhatrapati award winners list of last 10 years

Asked by admin @ in Environmental Sciences viewed by 813 persons

List of shri shiv chatrapati awards of last 10 years with the respective years they have won it

How to find group number of d block elements

Asked by admin @ in Chemistry viewed by 371 persons

(a) How is group, period and block of elements predicted. (b) Give the electronic configuration and in terms of period group and block where would you locate the elements with …

How to find the electronic configuration of an element

Asked by admin @ in Chemistry viewed by 355 persons

How to find out the electronic configuration of an element?

A programmer writes a program to find an element

Asked by admin @ in Computer Science viewed by 816 persons

A programmer writes a program to find an element in the array A[5] with the elements:8 30 40 45 70 the program is run to find a number X,that is …

How to find group and period of an element

Asked by admin @ in Chemistry viewed by 311 persons

How to find the group and period of a given element

How to find valency of an element in a compound

Asked by admin @ in Chemistry viewed by 324 persons

How to calculate the valency of a compound???

Most viewed questions in Computer Science


A programmer mistakenly writes gor instead of for

Asked by admin @ in Computer Science viewed by 19019 persons


Domestic data entry operator ncert book class 9 solutions

Asked by admin @ in Computer Science viewed by 15805 persons


Information technology code 402 class 9 solutions chapter 1

Asked by admin @ in Computer Science viewed by 10970 persons



Ncert solutions for class 8 computer chapter 1 computer system

Asked by admin @ in Computer Science viewed by 10401 persons


A scrum team works on a 4 weeks sprint

Asked by admin @ in Computer Science viewed by 8721 persons


Which of the following occupies more memory in c

Asked by admin @ in Computer Science viewed by 8135 persons



A database of motor vehicles has the base entity

Asked by admin @ in Computer Science viewed by 7841 persons


The network architecture can be termed as a mcq

Asked by admin @ in Computer Science viewed by 6486 persons


Cat5 and cat6 cabling refer to which reference model layer

Asked by admin @ in Computer Science viewed by 5788 persons



Class 7 computer chapter 3 questions and answers

Asked by admin @ in Computer Science viewed by 5691 persons


Choose the correct options about usability and user experience

Asked by admin @ in Computer Science viewed by 5474 persons


Which advocates daily team meetings for coordination and integration

Asked by admin @ in Computer Science viewed by 4980 persons



Which three security features match the database security level

Asked by admin @ in Computer Science viewed by 4970 persons


Which of the dbms package is not available

Asked by admin @ in Computer Science viewed by 4682 persons


________ aid a business grow and attain its objectives

Asked by admin @ in Computer Science viewed by 4486 persons