Your assignment is to write two functions, sum and product, that compute the sum and product of two binary numbers, each represented as a list. For example, sum([1,0,1], [0,0,1,1]) = [1,0,0,0,1] (since 5+12=17), and product([1,0,1], [0,1]) = [0,1,0,1] (since (5)(2) = 10).
Write the functions in an equational style in Astarte. Test your functions on at least the same numbers as in programming assignment 1.
Make your functions definitions simple. Include a comment for each explaining what it does (but not how it works). That is, give a contract for each function.
Keep track of your time, in just the same way as for programming assignment 1.
Do not start worrying about Astarte syntax until you have a set of equations that you believe are correct and complete, in the sense that every case is covered by at least one equation. When you think you have solid equational definitions, code them up.
You will find some helper functions useful. Write a function inc(x) that adds one to x. Think about the cases to handle.
Write a function sumWithCarry(x,y,c), where x and y are lists and c is either 0 or 1. It should produce the list that represents the sum x+y+c. Think about the cases.
You might find yet another helper function useful.
Write function sum. It should be trivial, since you have sumWithCarry.
Write function product. Think about the cases that you need, and then solve each case separately, and write an equation for each case. Be sure that you think the equations are true.
3675 Assn 2 your nameBe sure to include your name in the program.
The body of the email message should report your account of time spent, in hours. For example,
Learning language: 2.5 hr Development: 1 hr Debugging/testing: 1 hrOf course, the times shown here are only examples, and might not be representative of the times that you use.