TAILIEUCHUNG - learn prolog now phần 9

Một ngôn ngữ chính thức là chỉ đơn giản là một tập hợp các chuỗi. Ngôn ngữ chính thức 'Thuật ngữ được thiết kế để tương phản với các thuật ngữ tự nhiênBài giảng này có hai mục tiêu chính: 1. Để thảo luận về các thao tác cơ sở dữ liệu trong Prolog | 140 Chapter 9. A Closer Look at Terms X term no - termtype dead zed X . X complex_term X term no Exercise Write a program that defines the predicate groundterm Term which tests whether Term is a ground term. Ground terms are terms that don t contain variables. Here are examples of how the predicate should behave - groundterm X . no - groundterm french bic_mac le_bic_mac . yes - groundterm french whopper X . no Exercise Assume that we have the following operator definitions. - op 300 xfx are is_a . - op 300 fx likes . - op 200 xfy and . - op 100 fy famous . Which of the following is a wellformed term What is the main operator Give the bracketing. - X is_a witch. - harry and ron and hermione are friends. - harry is_a wizard and likes quidditch. - dumbledore isa famous famous wizard. Practical Session In this practical session we want to introduce some built-in predicates for printing terms onto the screen. The first predicate we want to look at is display 1 which takes a term and prints it onto the screen. - display loves vincent mia . loves vincent mia Yes - display jules eats a big kahuna burger . jules eats a big kahuna burger Yes More strictly speaking display prints Prolog s internal representation of terms. . Practical Session 141 - display 2 3 4 . 2 3 4 Yes In fact this property of display makes it a very useful tool for learning how operators work in Prolog. So before going on to learn more about how to write things onto the screen try the following queries. Make sure you understand why Prolog answers the way it does. - display a b c . - display 3 is 4 5 3 . - display 3 is 4 5 3 . - display a -b c d . - display a -b c d . So display is nice to look at the internal representation of terms in operator notation but usually we would probably prefer to print the user friendly notation instead. Especially when printing lists it would be much nicer to get a b c instead of . a. b. c . This is what the built-in predicate write 1 does. It takes a term .

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.