--
-- This file has been auto-generated by egison-translator.
--

assert
  "list's value pattern"
  (match [1, 2, 3] as list integer with
    | #([1] ++ 2 :: [3]) -> True
    | _ -> False)

assert
  "list's nil - case 1"
  (match [] as list integer with
    | [] -> True
    | _ -> False)

assert
  "list's nil - case 2"
  (match [1] as list integer with
    | [] -> False
    | _ -> True)

assertEqual
  "list's cons"
  (match [1, 2, 3] as list integer with
    | $n :: $ns -> (n, ns))
  (1, [2, 3])

assertEqual
  "list's cons with value pattern"
  (match [1, 2, 3] as list integer with
    | #1 :: $ns -> ns)
  [2, 3]

assertEqual
  "list's snoc"
  (match [1, 2, 3] as list integer with
    | snoc $n $ns -> (n, ns))
  (3, [1, 2])

assertEqual
  "list's snoc with value pattern"
  (match [1, 2, 3] as list integer with
    | snoc #3 $ns -> ns)
  [1, 2]

assertEqual
  "list's join"
  (matchAll [1, 2, 3] as list integer with
    | $xs ++ $ys -> (xs, ys))
  [([], [1, 2, 3]), ([1], [2, 3]), ([1, 2], [3]), ([1, 2, 3], [])]

assertEqual
  "list's join with value pattern"
  (match [1, 2, 3] as list integer with
    | #[1] ++ $ns -> ns)
  [2, 3]

assertEqual
  "list's nioj"
  (matchAll [1, 2, 3] as list integer with
    | nioj $xs $ys -> (xs, ys))
  [([], [1, 2, 3]), ([3], [1, 2]), ([2, 3], [1]), ([1, 2, 3], [])]

assertEqual
  "list's nioj with value pattern"
  (match [1, 2, 3] as list integer with
    | nioj #[3] $ns -> ns)
  [1, 2]

assertEqual
  "sorted-list - join-cons 1"
  (matchAll [3, 1, 2, 4] as sortedList integer with
    | _ ++ #3 :: $xs -> xs)
  [[1, 2, 4]]

assertEqual
  "sorted-list - join-cons 2"
  (matchAll [3, 1, 2, 4] as sortedList integer with
    | _ ++ #2 :: $xs -> xs)
  []

assert
  "multiset's nil - case 1"
  (match [] as multiset integer with
    | [] -> True
    | _ -> False)

assert
  "multiset's nil - case 2"
  (match [1] as multiset integer with
    | [] -> False
    | _ -> True)

assert
  "multiset's value pattern"
  (match [1, 1, 1, 2, 3] as multiset integer with
    | #([1] ++ (2 :: [1, 3]) ++ [1]) -> True
    | _ -> False)

assertEqual
  "multiset's cons"
  (matchAll [1, 2, 3] as multiset integer with
    | $n :: $ns -> (n, ns))
  [(1, [2, 3]), (2, [1, 3]), (3, [1, 2])]

assertEqual
  "multiset's cons with value pattern"
  (match [1, 2, 3] as multiset integer with
    | #2 :: $ns -> ns)
  [1, 3]

assertEqual
  "multiset's join"
  (matchAll [1, 2, 3] as multiset integer with
    | $xs ++ $ys -> (xs, ys))
  [ ([], [1, 2, 3])
  , ([1], [2, 3])
  , ([2], [1, 3])
  , ([3], [1, 2])
  , ([1, 2], [3])
  , ([1, 3], [2])
  , ([2, 3], [1])
  , ([1, 2, 3], []) ]

assertEqual
  "multiset's join with value pattern - case 1"
  (match [1, 2, 3] as multiset integer with
    | #[1] ++ $ns -> ns)
  [2, 3]

assertEqual
  "multiset's join with value pattern - case 2"
  (matchAll [1, 2, 3] as multiset integer with
    | #[1, 3] ++ $ys -> ys)
  [[2]]

assertEqual
  "multiset's join with value pattern - case 3"
  (matchAll [1, 2, 3] as multiset integer with
    | #[1, 5, 3] ++ $ys -> ys)
  []

assert
  "set's nil - case 1"
  (match [] as set integer with
    | [] -> True
    | _ -> False)

assert
  "set's nil - case 2"
  (match [1] as set integer with
    | [] -> False
    | _ -> True)

assertEqual
  "set's cons"
  (matchAll [1, 2, 3] as set integer with
    | $n :: $ns -> (n, ns))
  [(1, [1, 2, 3]), (2, [1, 2, 3]), (3, [1, 2, 3])]

assertEqual
  "set's cons with value pattern"
  (match [1, 2, 3] as set integer with
    | #2 :: $ns -> ns)
  [1, 2, 3]

assertEqual
  "set's join"
  (matchAll [1, 2, 3] as set integer with
    | $xs ++ $ys -> (xs, ys))
  [ ([], [1, 2, 3])
  , ([1], [1, 2, 3])
  , ([2], [1, 2, 3])
  , ([3], [1, 2, 3])
  , ([1, 2], [1, 2, 3])
  , ([1, 3], [1, 2, 3])
  , ([2, 3], [1, 2, 3])
  , ([1, 2, 3], [1, 2, 3]) ]

assertEqual
  "set's join with value pattern 1"
  (matchAll [1, 2, 3] as set integer with
    | #[1, 3] ++ $ys -> ys)
  [[1, 2, 3]]

assertEqual
  "set's join with value pattern 2"
  (matchAll [1, 2, 3] as set integer with
    | #[1, 5, 3] ++ $ys -> ys)
  []

assertEqual "nth" (nth 1 [1, 2, 3]) 1

assertEqual "take" (take 2 [1, 2, 3]) [1, 2]

assertEqual "drop" (drop 2 [1, 2, 3]) [3]

assertEqual "takeAndDrop" (takeAndDrop 2 [1, 2, 3]) ([1, 2], [3])

assertEqual "takeWhile" (takeWhile (< 10) primes) [2, 3, 5, 7]

assertEqual "head" (head [1, 2, 3]) 1
assertEqual "tail" (tail [1, 2, 3]) [2, 3]
assertEqual "last" (last [1, 2, 3]) 3
assertEqual "init" (init [1, 2, 3]) [1, 2]

assertEqual "uncons" (uncons [1, 2, 3]) (1, [2, 3])
assertEqual "unsnoc" (unsnoc [1, 2, 3]) ([1, 2], 3)

assertEqual "isEmpty" (isEmpty [])  True
assertEqual "isEmpty" (isEmpty [1]) False

assertEqual "length" (length [1, 2, 3]) 3

assertEqual "map" (map (* 2) [1, 2, 3]) [2, 4, 6]

assertEqual "map2" (map2 (*) [1, 2, 3] [10, 20, 30]) [10, 40, 90]

assertEqual "filter" (filter (\n -> n % 2 = 1) [1, 2, 3]) [1, 3]

assertEqual "zip" (zip [1, 2, 3] [10, 20, 30]) [(1, 10), (2, 20), (3, 30)]

assertEqual "lookup" (lookup 2 [(1, 10), (2, 20), (3, 30)]) 20

assertEqual "foldr" (foldr (\n ns -> n :: ns) [] [1, 2, 3]) [1, 2, 3]

assertEqual "foldl" (foldl (\ns n -> n :: ns) [] [1, 2, 3]) [3, 2, 1]

assertEqual "scanl" (scanl (*) 2 [2, 2, 2]) [2, 4, 8, 16]

assertEqual "concat" (concat [[1, 2], [3, 4, 5]]) [1, 2, 3, 4, 5]

assertEqual "reverse" (reverse [1, 2, 3]) [3, 2, 1]

assertEqual "intersperse"
  (intersperse [0] [[1, 2], [3, 3], [4], []])
  [[1, 2], [0], [3, 3], [0], [4], [0], []]

assertEqual "intercalate"
  (intercalate [0] [[1, 2], [3, 3], [4], []])
  [1, 2, 0, 3, 3, 0, 4, 0]

assertEqual "split"
  (split [0] [1, 2, 0, 3, 3, 0, 4, 0])
  [[1, 2], [3, 3], [4], []]

assertEqual "splitAs"
  (splitAs integer [0] [1, 2, 0, 3, 3, 0, 4, 0])
  [[1, 2], [3, 3], [4], []]

assertEqual "findCycle"
  (findCycle [1, 3, 4, 5, 2, 7, 5, 2, 7, 5, 2, 7])
  ([1, 3, 4], [5, 2, 7])

assertEqual "repeat" (take 5 (repeat [1, 2, 3])) [1, 2, 3, 1, 2]

assertEqual "repeat1" (take 5 (repeat1 2)) [2, 2, 2, 2, 2]

assertEqual "all" (all (= 1) [1, 1, 1]) True

assertEqual "all" (all (= 1) [1, 1, 2]) False

assertEqual "any" (any (= 1) [0, 1, 0]) True

assertEqual "any" (any (= 1) [0, 0, 0]) False

assertEqual "from" (take 3 (from 2)) [2, 3, 4]

assertEqual "between" (between 2 5) [2, 3, 4, 5]

assertEqual "add" (add 1 [2, 3]) [2, 3, 1]

assertEqual "add" (add 1 [1, 2, 3]) [1, 2, 3]

assertEqual "addAs" (addAs integer 1 [2, 3]) [2, 3, 1]

assertEqual "addAs" (addAs integer 1 [1, 2, 3]) [1, 2, 3]

assertEqual "deleteFirst" (deleteFirst 2 [1, 2, 3, 2]) [1, 3, 2]

assertEqual "deleteFirstAs" (deleteFirstAs integer 2 [1, 2, 3, 2]) [1, 3, 2]

assertEqual "delete" (delete 2 [1, 2, 3, 1, 2, 3]) [1, 3, 1, 3]

assertEqual "deleteAs" (deleteAs integer 2 [1, 2, 3, 1, 2, 3]) [1, 3, 1, 3]

assertEqual "difference" (difference [1, 2, 3] [1, 3]) [2]

assertEqual "differenceAs" (differenceAs integer [1, 2, 3] [1, 3]) [2]

assertEqual "union" (union [1, 2, 3] [1, 3, 4]) [1, 2, 3, 4]

assertEqual "unionAs" (unionAs integer [1, 2, 3] [1, 3, 4]) [1, 2, 3, 4]

assertEqual "intersect" (intersect [1, 2, 3] [1, 3, 4]) [1, 3]

assertEqual "intersectAs" (intersectAs integer [1, 2, 3] [1, 3, 4]) [1, 3]

assertEqual "member" (member 1 [1, 3, 1, 4]) True

assertEqual "member" (member 2 [1, 3, 1, 4]) False

assertEqual "memberAs" (memberAs integer 1 [1, 3, 1, 4]) True

assertEqual "memberAs" (memberAs integer 2 [1, 3, 1, 4]) False

assertEqual "count" (count 1 [1, 3, 1, 4]) 2

assertEqual "countAs" (countAs integer 1 [1, 3, 1, 4]) 2

assertEqual "frequency" (frequency [1, 3, 1, 4]) [(1, 2), (3, 1), (4, 1)]

assertEqual "frequencyAs"
  (frequencyAs integer [1, 3, 1, 4])
  [(1, 2), (3, 1), (4, 1)]

assertEqual "unique" (unique [1, 2, 3, 2, 1, 4]) [1, 2, 3, 4]

assertEqual "uniqueAs" (uniqueAs integer [1, 2, 3, 2, 1, 4]) [1, 2, 3, 4]
