CS 380 Homework #7
Prof. Richard Eisenberg
Spring 2017
Suggested due date: Wednesday, April 5, 2017
Note: There are a lot of functions this week. The long list is meant to give you flexibility in choosing what you care to work on. Don’t spend more than, say, 8 hours on this!
Write the following functions, adapted from their list versions. You will need EVec
and Fin
for these. Use as tight a constraint on EVec
as you can.
concatMap
unfoldr
takeWhile
dropWhile
dropWhileEnd
filter
(!!)
(uses Fin
)elemIndex
(uses Fin
)elemIndices
(uses EVec
and Fin
)findIndex
(uses Fin
)findIndices
(uses EVec
and Fin
)nub
delete
(this can get a tighter constraint than, say, filter
)(\\)
union
intersect
The following functions cannot be translated to work on Vec
with the existing structures we have. But you know enough to come up with fresh GADTs to encode the right invariants. Aim for your type indices to be as expressive as possible.
span
break
partition
group