Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def isSorted[A](collection: Array[A], gt: (A, A) => Boolean): Boolean = {
- def geq(a: A, b: A): Boolean = gt(a, b) || (!gt(a, b) && !gt(b, a))
- (collection.init, collection.tail).zipped.forall(geq)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement