Reference no: EM132253924
Programming Languages Assignment: four small F# functions
Overview - Write 4 small functions, 2 in a tail-recursive manner and 2 using a higher-order approach. The exercise is setup on Codio, but you can work in whatever environment you prefer. Regardless of where you work, be sure to submit the 4 functions separately as described in the next section.
Exercises -
Exercise 1: sum4x1 L in a tail-recursive manner
Login to Codio and edit the file "hw0801.fs". Read the comments:
Given a list L of integers, computes sum(4x+1):x in L.
NOTE: write a tail-recursive version using a helper function; do not change the API of the original sum4x1 function.
Write the required function, which will require the definition of a helper function that is tail-recursive. Notice there is no main program. To test your work, open a terminal window and load the file into F# interactive.
Exercise 2: sum4x1 L using a higher-order approach
Edit the file "hw0802.fs". Read the comments, and write the necessary function using a higher-order approach, List.map, and List.sum. Test using F# interactive.
Exercise 3: countBetween A B L in a tail-recursive manner
Edit the file "hw0803.fs". Read the comments, and write the necessary function in a tail-recursive manner. Test using F# interactive.
Exercise 4: countBetween A B L using a higher-order approach
Edit the file "hw0804.fs". Read the comments, and write the necessary function using a higher-order approach. Test using F# interactive.
Attachment:- Assignment Files.rar