>>> fst (splitAt 0 undefined) []
>>> take 1 (fst (splitAt 10 (1 : undefined))) [1]
>>> splitAt 6 "Hello World!" ("Hello ","World!")
>>> splitAt 3 [1,2,3,4,5] ([1,2,3],[4,5])
>>> splitAt 1 [1,2,3] ([1],[2,3])
>>> splitAt 3 [1,2,3] ([1,2,3],[])
>>> splitAt 4 [1,2,3] ([1,2,3],[])
>>> splitAt 0 [1,2,3] ([],[1,2,3])
>>> splitAt (-1) [1,2,3] ([],[1,2,3])
splitAtExact n xs = | n >= 0 && n <= length xs = splitAt n xs | otherwise = error "some message"
splitAtEnd 3 "hello" == ("he","llo") splitAtEnd 3 "he" == ("", "he") \i xs -> uncurry (++) (splitAt i xs) == xs \i xs -> splitAtEnd i xs == (dropEnd i xs, takeEnd i xs)
>>> splitAt 6 "Hello World!" ("Hello ","World!") >>> splitAt 3 [1,2,3,4,5] ([1,2,3],[4,5]) >>> splitAt 1 [1,2,3] ([1],[2,3]) >>> splitAt 3 [1,2,3] ([1,2,3],[]) >>> splitAt 4 [1,2,3] ([1,2,3],[]) >>> splitAt 0 [1,2,3] ([],[1,2,3]) >>> splitAt (-1) [1,2,3] ([],[1,2,3])It is equivalent to (take n xs, drop n xs) when n is not _|_ (splitAt _|_ xs = _|_). splitAt is an instance of the more general genericSplitAt, in which n may be of any integral type.
splitAt 6 "Hello World!" == ("Hello ","World!") splitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5]) splitAt 1 [1,2,3] == ([1],[2,3]) splitAt 3 [1,2,3] == ([1,2,3],[]) splitAt 4 [1,2,3] == ([1,2,3],[]) splitAt 0 [1,2,3] == ([],[1,2,3]) splitAt (-1) [1,2,3] == ([],[1,2,3])It is equivalent to (take n xs, drop n xs) when n is not _|_ (splitAt _|_ xs = _|_). splitAt is an instance of the more general genericSplitAt, in which n may be of any integral type.
>>> deck <- evalRandIO $ shuffle $ (fullDeck :: [PlayingCard]) >>> draw1 5 deck Just ([Six of Clubs,Ace of Hearts,Nine of Hearts,Four of Hearts,Two of Diamonds],[King of Diamonds,Queen of Spades,Four of Spades,Seven of Hearts,Five of Hearts,Seven of Clubs,Three of Hearts,Ace of Spades,Three of Diamonds,Seven of Diamonds,Two of Clubs,Five of Spades,King of Hearts,Jack of Hearts,Queen of Hearts,Ten of Clubs,Five of Clubs,Eight of Spades,Ace of Clubs,King of Clubs,Five of Diamonds,Queen of Diamonds,Eight of Hearts,Four of Clubs,Three of Clubs,Jack of Clubs,Jack of Diamonds,Ten of Diamonds,Queen of Clubs,Eight of Diamonds,Six of Diamonds,Eight of Clubs,Three of Spades,Two of Hearts,Six of Spades,King of Spades,Ten of Hearts,Nine of Spades,Nine of Diamonds,Two of Spades,Ten of Spades,Nine of Clubs,Four of Diamonds,Ace of Diamonds,Six of Hearts,Seven of Spades,Jack of Spades])