= Solution
A shared <recursion> computes both components:
``
split :: Int -> [a] -> ([a],[a])
split n xs | n <= 0 = ([],xs)
split _ [] = ([],[])
split n (x:xs) = (x:ys,zs)
where (ys,zs) = split (n-1) xs
``
For a defined count and a spine with $m$ available constructors before termination, each of `take` and `drop` makes $\min(\max(n,0),m)$ recursive calls, whereas `split` makes that many once. \b[The number of recursive calls is halved.] The <irrefutable pattern> in the local pair binding also avoids evaluating the recursive pair merely to expose the first output element.
On <proper lazy lists> this has the intended two component values. There is a small <bottom value> distinction outside that domain: the displayed single-pass definition must inspect a positive-count input spine before returning its outer pair, whereas the literal expression `(take n xs, drop n xs)` exposes the pair constructor even if `xs` is undefined. The algorithmic answer concerns the two components and the stated call count; it need not silently claim equality under a test that observes this outer constructor alone.
Back to article page