Download presentation

Presentation is loading. Please wait.

Published byRicky Gravely Modified over 2 years ago

1
Built-in Functions listing(fruit).: Lists all the objects within this relation halt. Exit from Prolog write(X). /* Write to console */ nl /* New Line */ ! /* CUT Backtrack */

2
Example I: Simple Program has(jack,apples). has(ann,plums). has(dan,money). fruit(apples). fruit(plums).Queries: has(jack,_). /* Don’t care about second operand */ has(X,apples),has(Y,plums). /* who has apples and who has plums? */ has(dan,X),fruit(X). /* has Dan fruits? */ has(X,Y),not fruit(Y). /* does someone have something else? */

3
Basic Arithmetic ?- X is 5+4, Y is 5-4. X = 9, Y = 1 ?- X is 5*4, Y is 2^3. X = 20, Y = 8 ?- X is sqrt(3),Y is 3^0.5. X = 1.73205080756888, Y = 1.73205080756888 ?- X is 8 mod 3. X = 2

4
Example II: Arithmetic abs(X,X):- X >= 0, !. abs(X,Y):- Y is -X. ?- abs(0,R). R = 0 ?- abs(-9,R). R = 9

5
Example III: Lists Find Member member(X,[X|_]). member(X,[_|T]):- member(X,T). ?- member(b,[a,v,b,c]). yes ?- member(a,[b,c,g]).no Print List my_write([]). my_write([X|R]): write(X),nl,my_write(R). ?- my_write([a,b,c]). a b c yes

Similar presentations

OK

My Favorite Song “Song Title” Name. Information about the Artist The five ws about the artist Who they are What type of music they make When did the y.

My Favorite Song “Song Title” Name. Information about the Artist The five ws about the artist Who they are What type of music they make When did the y.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Free ppt on mobile number portability ppt Ppt on high voltage dc transmission Ppt on water activity vs moisture Ppt on javascript events handling Ppt on introduction to object-oriented programming pdf Marketing mix ppt on nokia x Ppt on coalition government in england Ppt on vehicle chassis Ppt on us polo brand Ppt on unity in diversity in india