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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started