Find the last element of a list in prolog


Asked by admin @ in Computer Science viewed by 299 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 309 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 320 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 358 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 343 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 384 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 313 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 376 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 329 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 313 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 807 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 364 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 352 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 809 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 305 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 318 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 19012 persons


Domestic data entry operator ncert book class 9 solutions

Asked by admin @ in Computer Science viewed by 15786 persons


Information technology code 402 class 9 solutions chapter 1

Asked by admin @ in Computer Science viewed by 10957 persons



Ncert solutions for class 8 computer chapter 1 computer system

Asked by admin @ in Computer Science viewed by 10392 persons


A scrum team works on a 4 weeks sprint

Asked by admin @ in Computer Science viewed by 8715 persons


Which of the following occupies more memory in c

Asked by admin @ in Computer Science viewed by 8124 persons



A database of motor vehicles has the base entity

Asked by admin @ in Computer Science viewed by 7833 persons


The network architecture can be termed as a mcq

Asked by admin @ in Computer Science viewed by 6475 persons


Cat5 and cat6 cabling refer to which reference model layer

Asked by admin @ in Computer Science viewed by 5781 persons



Class 7 computer chapter 3 questions and answers

Asked by admin @ in Computer Science viewed by 5680 persons


Choose the correct options about usability and user experience

Asked by admin @ in Computer Science viewed by 5467 persons


Which advocates daily team meetings for coordination and integration

Asked by admin @ in Computer Science viewed by 4973 persons



Which three security features match the database security level

Asked by admin @ in Computer Science viewed by 4963 persons


Which of the dbms package is not available

Asked by admin @ in Computer Science viewed by 4677 persons


________ aid a business grow and attain its objectives

Asked by admin @ in Computer Science viewed by 4479 persons