Lab1
Learning objective: To write and test a function in Daml
Prerequisite
- Daml SDK installed and setup
- Daml Fundamentals Training: Functional Programming in Daml - Lessons 1 to 5 completed.
This problem has three parts.
-
Write a function named quadFunction that takes three integers for x, y, and z. It returns the value of
-
Write a test-script that
-
Tests quadFunction as
quadFunction 1 2 3
-
Prints the result in the Script output as shown below:
Transactions: Active contracts: Return value: {} Trace: 10
- Write a lambda function in the test script that does the same calculation as the quadFunction described above and prints the same result as shown above.
This problem has three parts
-
Write a function named doubleMe that takes an integer and returns its double
-
Using the doubleMe function, write another function called doubleUs that takes two integers, doubles each of them, adds them up and returns the result.
As a sample, the following statements:
debug $ doubleMe 3 debug $ doubleUs 3 4
will produce the following result:
Transactions: Active contracts: Return value: {} Trace: 6 14
-
Write an expression in the test-script using doubleUs with an inFix notation to get the same result as
debug $ doubleUs 3 4