






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This lecture was delivered by Prof. Sunil Bhedi at Amrita Vishwa Vidyapeetham for Data Structures. It includes: Recursion , Person , Drink , Define , Clear , Elegant , Code , Best , Processed
Typology: Slides
1 / 10
This page cannot be seen from the preview
Don't miss anything!
30/09/04 1
30/09/04 2
30/09/04 4
| ?- person(Nm,london,Age) = person(bob,london,48). Nm = bob, Age = 48? yes | ?- person(Someone,_,45) = person(harry,dundee,45). Someone = harry? yes
30/09/04 5
|?-addr(flat(4),street(‘Home Str.’),postcode(eh8_9lw))
= addr(flat(Z),Yy,postcode(Xxx)). Z = 4, Yy = street(‘Home Str.’), Xxx = eh8_9lw? yes
Remember to close brackets!
Reported variables are ordered according to number of characters in the variable name.
30/09/04 7
1 2 3 1 2
|?- [Any, list, ‘of elements’] = X. X = [Any, list, ‘of elements’]? yes
30/09/04 8
|?-[a,B,c,D]=[A,b,C,d]. |?-[(a+X),(Y+b)]=[(W+c),(d+b)].
A = a, W = a,
B = b, X = c,
C = c, Y = d?
D = d? yes
yes
|?- [[X,a]]=[b,Y]. |?-[[a],[B,c],[]]=[X,[b,c],Y].
no B = b,
X = [a], Y = []? yes
Length 1 Length 2
30/09/04 10
|?-[a,b,c,d]=[Head|Tail]. |?-[a,b,c,d]=[X|[Y|Z]]. Head = a, X = a, Tail = [b,c,d]? Y = b, yes Z = [c,d]; yes
|?-[a] = [H|T]. |?-[a,b,c]=[W|[X|[Y|Z]]]. H = a, W = a, T = []; X = b, yes Y = c, Z = []? yes
|?-[] = [H|T]. |?-[a|[b|[c|[]]]]= List. no List = [a,b,c]? yes