Using F# 1) Write an F# function interleave(xs,ys) that interleaves two lists: A
ID: 3891032 • Letter: U
Question
Using F#
1) Write an F# function interleave(xs,ys) that interleaves two lists:
Assume that the two lists have the same length.
2) Write an F# function cut xs that cuts a list into two equal parts:
Assume that the list has even length.
To implement cut, first define an auxiliary function gencut(n, xs) that cuts xs into two pieces, where n gives the size of the first piece:
Paradoxically, although gencut is more general than cut, it is easier to write! (This is an example of Polya's Inventor's Paradox: "The more ambitious plan may have more chances of success.")
Another Hint: To write gencut efficiently, it is quite convenient to use F#'s local let expression (as in the cos_squared example in the Notes).
Explanation / Answer
1.
2.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.