
17 Nov
2006
17 Nov
'06
5:02 a.m.
Jón Fairbairn
"Jason Dagit"
writes: Well, this is basically just a zip with a special base case. But you [...] I wonder if there is mileage to be had from persuing something like this, rather different (off top of head, very provisional, E&OE &c) approach:
extend_infinitely l = map Just l ++ repeat Nothing promote1 rel (Just a) b = rel a b promote1 rel Nothing b = False is_pfx_of l1 l2 = and (zipWith (promote1 (==)) (extend_infinitely l2) l1)
or, possibly better extend_infinitely l = map Just l ++ repeat Nothing is_pfx_of l1 l2 = and (zipWith (==) (extend_infinitely l2) (map Just l1)) -- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk