Prolog Exercises - PowerPoint PPT Presentation

1 / 5
About This Presentation
Title:

Prolog Exercises

Description:

ali likes cinema and reading. Print what ali likes. like(ali,reading). like(ali,cinema). like(ali,What). Exercise 2. Write the prolog code of; Clauses consists of: ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 6
Provided by: pcl691
Category:

less

Transcript and Presenter's Notes

Title: Prolog Exercises


1
Prolog Exercises
  • CENG 212Concepts of Programming Languages

2
Exercise 1
  • Write the prolog code of
  • Clauses consists of
  • ali likes cinema and reading
  • Print what ali likes
  • like(ali,reading).
  • like(ali,cinema).
  • like(ali,What).

3
Exercise 2
  • Write the prolog code of
  • Clauses consists of
  • ali likes football
  • tolga likes basketball
  • can likes swimming
  • canan likes tennis
  • yesim likes a hobby if tolga likes a hobby
  • Does yesim like football?
  • Hint
  • Variables starts with capital letter.
  • If condition
  • like(x,Hobby) - like(y,Hobby).

4
Exercise 3
  • Write the prolog code of
  • Clauses consists of
  • Defining car facts
  • Ex car(mark,distance,age,color,price).
  • renault,100,5,gray,20
  • opel,20.5,1,blue,35
  • fiat,120,15,black,10
  • Print the mark,age,color of the cars
  • where age lt 7.
  • Note distance and price symbols are anonymous,
    insert underscore (_) for these symbols.

5
Exercise 4
  • Print the match fixture of teams that is in group
    a.
  • Group a
  • germany, brazil, turkey, korea
  • Group b
  • china, usa, chile, italy
  • Hint
  • , operator is defined as and operator.
  • not operator is the negation.
Write a Comment
User Comments (0)
About PowerShow.com