Skip to content

Latest commit

 

History

History
99 lines (67 loc) · 2.42 KB

README.md

File metadata and controls

99 lines (67 loc) · 2.42 KB

Assignment7

The purpose of this assignment is to get familiar with the structure of a Julia Project, implement a few functions, and run the tests. I've recorded a YouTube video that describes the expectations for this assignment

https://youtu.be/1ho6PK8whD4

In the src directory of the repository you will find a file called assignment7.jl. Edit that file to complete the following tasks:

  1. Implement the function add_positional_arguments() so that it accepts three positional arguments and returns the sum of those arguments. The third positional argument should have a default value of 2. For example, calling the function with

    add_positional_arguments(1, 2, 3)  

    should return 6.

    Calling the function with

    add_positional_arguments(1, 2)

    should return 5.

  2. Next create a unicode shorthand function name for add_positional_arguments. Use the symbol Σ to create a function that has idential behavior, i.e.

    Σ(1, 2, 3)

    should return 6.

    Calling the function with

    Σ(1, 2)

    should return 5.

  3. Implement the function add_keyword_arguments() so that it accepts three keyword arguments and returns the sum of those arguments. The keyword argument names should be a, b, and c and they should have default values of 1, 2, and 3, respectively. For example, calling the function with

    add_keyword_arguments(a=1, b=2, c=3)

    should return 6.

    Calling the function with

    add_positional_arguments(a=1, b=2)

    should return 6.

  4. Implement the function return_anonymous_function() to return a function that implements the equation

    this should just be a one-line implementation that uses an anonymous function. Running the following commands

    f = return_anonymous_function()
    f(2)

    should return 5. And

    f = return_anonymous_function()
    f(3)

    should return 10.

Testing

To see if you answers are correct, run the following command at the Terminal command line from the repository's root directory

julia --project=. -e "using Pkg; Pkg.test()"

the tests will run and report if passing or failing.