spanNeighbor :: (a -> a -> Bool) -> [a] -> ([a],[a])
spanNeighbor p = go False
  where
    go _ (x1:rest@(x2:_))
       | p x1 x2   = let (ys, zs) = go True rest in (x1:ys,zs)
    go carry (x1:rest)
       | carry     = ([x1], rest)
    go _ xs      = ([], xs)
spanNeighbor :: (a -> a -> Bool) -> [a] -> ([a],[a])
spanNeighbor p = go False
  where
    go _ (x1:rest@(x2:_))
       | p x1 x2   = let (ys, zs) = go True rest in (x1:ys,zs)
    go carry (x1:rest)
       | carry     = ([x1], rest)
    go _ xs      = ([], xs)
spanNeighbor p = go False
  where
    go _ (x1:rest@(x2:_))
       | p x1 x2   = let (ys, zs) = go True rest in (x1:ys,zs)
    go carry (x1:rest)
       | carry     = ([x1], rest)
    go _ xs      = ([], xs)