I've got a function that will take a list and return a list of sublists of a specified length:
*Main> neighbors 3 [1,2,3,4]
[[1,2,3],[2,3,4]]
neighbors :: Int -> [a] -> [[a]]
neighbors n xs =
let ys = take n xs
zs = drop 1 xs
in if (length ys < n)
then []
else ys : neighbors n zs
While it works, it doesn't look particularly "Haskell-y" to me, so I'm thinking there might be a pattern-match to do the same thing. Is there? Or, perhaps, I'm missing a different, tacit, way of doing this? I've looked at the various split libraries, and https://wiki.haskell.org/Let_vs._Where gave me the tools to get the function working at all.