Skip to content

Latest commit

 

History

History
76 lines (45 loc) · 1.57 KB

fundamentals-fp-lab1.md

File metadata and controls

76 lines (45 loc) · 1.57 KB

Lab1

Learning objective: To write and test a function in Daml

Prerequisite

  1. Daml SDK installed and setup
  2. Daml Fundamentals Training: Functional Programming in Daml - Lessons 1 to 5 completed.

Problem statement 1

This problem has three parts.

  1. Write a function named quadFunction that takes three integers for x, y, and z. It returns the value of

    quadEquation

  2. 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
    
    
  1. 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.

Problem statement 2

This problem has three parts

  1. Write a function named doubleMe that takes an integer and returns its double

  2. 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
    
  3. Write an expression in the test-script using doubleUs with an inFix notation to get the same result as

    debug $ doubleUs 3 4