Use mathematical induction on , which is finite even when the list is infinite. At , the left side is The last step applies the induction hypothesis to the tail. A bottom value tail is allowed: for a wholly undefined list and a positive count both sides are undefined. Thus the equality is observationally valid for finite and infinite lists; no evaluation of an infinite length is used.
[] ++ xs = xs. For the successor step, an empty list gives []; for x:xs, the defining equations and list concatenation givetake (n+1) (x:xs) ++ drop (n+1) (x:xs)
= (x : take n xs) ++ drop n xs
= x : (take n xs ++ drop n xs)
= x : xs Articles by others on the same topic
There are currently no matching articles.