Question: Code in F# Assignment1.fs implements a function oddJoin : a list list -> a list using functions from the List module. (i) Can either or

Code in F#

Assignment1.fs implements a function oddJoin : a list list -> a list using functions from the List module. (i) Can either or both the folds in the implementation be replaced with foldBacks? Explain your answer. (ii) Implement oddJoin2 : a list list -> a list so that it does the same as oddJoin, but directly using recursion, without using any List functions. You may wish to implement a recursive helper function for one of the folds.

// oddJoin : 'a list list -> 'a list

let oddJoin xss =

let oddLength xs = List.fold (fun b _ -> not b) false xs

xss |> List.filter oddLength |> List.fold (@) []

(* ANSWER 6(i) HERE:

*)

// oddJoin2 : 'a list list -> 'a list

let rec oddJoin2 xss =

failwith "Not implemented"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!