Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genetic Databases

Authors: Martin J. Bishop

1st Edition

0121016250, 978-0121016258

More Books

Students also viewed these Databases questions