Write a predicate weird_sum(List, Result) which takes a List of numbers, and computes the sum of the squares of the numbers in the list that are greater than or equal to 5, minus the sum of the absolute values of the numbers that are less than or equal to 2. For example:
?- weird_sum([3,6,2,-1], Result).
Result = 33
That’s 6×6 – 2 – 1.
(a) it is the value of the item, not its position in the list, that should be tested to see if it is greater than or equal to 5, or less than or equal to 2.
(b) you are not required to check whether the items in the list are numbers.
Think carefully about how the predicate should behave on the empty list — should it fail or is there a reasonable value that Result can be bound to?
Suppose that a set of family relationships have been loaded into Prolog using the same format as family.pl
NOTE: do not include these in your solution file.
We assume that each person will have the same family name as their father, but that married women retain their original birth name.
Write a predicate same_name(Person1,Person2) that succeeds if it can be deduced from the facts in the database that Person1 and Person2 will have the same family name. (It is ok if your code returns true multiple times). For example:
?- same_name(pat, brian).
?- same_name(jenny, jim).
Note that your same_name predicate will be tested with different facts to those in family.pl
Write a predicate log_table(NumberList, ResultList) that binds ResultList to the list of pairs consisting of a number and its log, for each number in NumberList. For example:
?- log_table([1,3.7,5], Result).
Result = [[1, 0.0], [3.7, 1.308332819650179], [5, 1.6094379124341003]].
Note that the Prolog built-in function log computes the natural logarithm, and that it needs to be evaluated using is to actually compute the log:
?- X is log(3.7).
X = 1.308332819650179.
?- X = log(3.7).
X = log(3.7).
Any list of integers can (uniquely) be broken into “parity runs” where each run is a (maximal) sequence of consecutive even or odd numbers within the original list. For example, the list
List = [8,0,4,3,7,2,-1,9,9]
can be broken into [8, 0, 4], [3, 7],  and [-1, 9, 9]
Write a predicate paruns(List, RunList) that converts a list of numbers into the corresponding list of parity runs. For example:
?- paruns([8,0,4,3,7,2,-1,9,9], RunList).
RunList = [[8, 0, 4], [3, 7], , [-1, 9, 9]]
Note: you can find out how to test if a number is even or odd from the Prolog Dictionary
In this question we consider binary trees which are represented as either empty or tree(L, Num, R), where L and R are the left and right subtrees and Num is a number.
A binary tree of numbers is called a heap (or, it is said to satisfy the heap property) if, for every non-leaf node in the tree, the number stored at that node is less than or equal to the number stored at each of its children. For example, the following tree satisfies the heap property, because 3 ≤ 5, 5 ≤ 8 and 5 ≤ 7.
On the other hand, the following tree does not satisfy the heap property, because 6 is not less than or equal to 5.
Write a predicate is_heap(Tree) which returns true if Tree satisfies the heap property, and false otherwise. For example:
Our Service Charter
Excellent Quality / 100% Plagiarism-FreeWe employ a number of measures to ensure top quality essays. The papers go through a system of quality control prior to delivery. We run plagiarism checks on each paper to ensure that they will be 100% plagiarism-free. So, only clean copies hit customers’ emails. We also never resell the papers completed by our writers. So, once it is checked using a plagiarism checker, the paper will be unique. Speaking of the academic writing standards, we will stick to the assignment brief given by the customer and assign the perfect writer. By saying “the perfect writer” we mean the one having an academic degree in the customer’s study field and positive feedback from other customers.
Free RevisionsWe keep the quality bar of all papers high. But in case you need some extra brilliance to the paper, here’s what to do. First of all, you can choose a top writer. It means that we will assign an expert with a degree in your subject. And secondly, you can rely on our editing services. Our editors will revise your papers, checking whether or not they comply with high standards of academic writing. In addition, editing entails adjusting content if it’s off the topic, adding more sources, refining the language style, and making sure the referencing style is followed.
Confidentiality / 100% No DisclosureWe make sure that clients’ personal data remains confidential and is not exploited for any purposes beyond those related to our services. We only ask you to provide us with the information that is required to produce the paper according to your writing needs. Please note that the payment info is protected as well. Feel free to refer to the support team for more information about our payment methods. The fact that you used our service is kept secret due to the advanced security standards. So, you can be sure that no one will find out that you got a paper from our writing service.
Money Back GuaranteeIf the writer doesn’t address all the questions on your assignment brief or the delivered paper appears to be off the topic, you can ask for a refund. Or, if it is applicable, you can opt in for free revision within 14-30 days, depending on your paper’s length. The revision or refund request should be sent within 14 days after delivery. The customer gets 100% money-back in case they haven't downloaded the paper. All approved refunds will be returned to the customer’s credit card or Bonus Balance in a form of store credit. Take a note that we will send an extra compensation if the customers goes with a store credit.
24/7 Customer SupportWe have a support team working 24/7 ready to give your issue concerning the order their immediate attention. If you have any questions about the ordering process, communication with the writer, payment options, feel free to join live chat. Be sure to get a fast response. They can also give you the exact price quote, taking into account the timing, desired academic level of the paper, and the number of pages.