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
In the src
directory of the repository you will find a file called
assignment7.jl
. Edit that file to complete the following tasks:
-
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 of2
. For example, calling the function withadd_positional_arguments(1, 2, 3)
should return
6
.Calling the function with
add_positional_arguments(1, 2)
should return
5
. -
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
. -
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 bea
,b
, andc
and they should have default values of1
,2
, and3
, respectively. For example, calling the function withadd_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
. -
Implement the function
return_anonymous_function()
to return a function that implements the equationthis 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
. Andf = return_anonymous_function() f(3)
should return
10
.
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.