Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def make_huge_list(size: Int) = {
- @scala.annotation.tailrec
- def inner_make_list(size: Int, acc: List[Char]) : List[Char] = {
- if (size == 0) acc
- else inner_make_list(size-1, 'X' :: acc)
- }
- if (size <= 0) List()
- else inner_make_list(size, List())
- }
- def huge_balanced: List[Char] = List.concat("(".toList, make_huge_list(999998), ")".toList);
- def huge_unbalanced: List[Char] = List.concat(make_huge_list(999999), ")".toList);
- test("huge string balanced") {
- assert(balance(huge_balanced))
- }
- test("huge string unbalanced") {
- assert(!balance(huge_unbalanced))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement