Consider the following Prolog program, written to implement a BNF grammar: The first two answers generated by the above
Posted: Sun May 15, 2022 8:03 am
Consider the following Prolog program, written to implement a
BNF grammar:
The first two answers generated by the above database to the
query generate( Z ) are Z = a and
Z = b. Indicate the next four answers generated by
the database:
1.____________ 2.____________ 3.____________ 4.____________
A list of numbers in monotonically increasing if every number in
the list is greater than or equal to the previous number in the
list. E.g., [ 1 2 2 3 ] is monotonically increasing whereas [ 1 2 1
3 ] is not. Write Prolog clauses to check if an input list is
monotonically increasing.
The median of a monotonic list of numbers is given by (first
number + last number) / 2. Write Prolog clauses to calculate the
median of an input list of numbers, assuming it is monotonically
increasing. Hint:One way to solve this problem is
to first write clauses to obtain the last number in a list.
BNF grammar:
The first two answers generated by the above database to the
query generate( Z ) are Z = a and
Z = b. Indicate the next four answers generated by
the database:
1.____________ 2.____________ 3.____________ 4.____________
A list of numbers in monotonically increasing if every number in
the list is greater than or equal to the previous number in the
list. E.g., [ 1 2 2 3 ] is monotonically increasing whereas [ 1 2 1
3 ] is not. Write Prolog clauses to check if an input list is
monotonically increasing.
The median of a monotonic list of numbers is given by (first
number + last number) / 2. Write Prolog clauses to calculate the
median of an input list of numbers, assuming it is monotonically
increasing. Hint:One way to solve this problem is
to first write clauses to obtain the last number in a list.