[Haskell] (no subject)

Boyko Bantchev bbbfp at mail.bg
Tue Jun 5 02:14:42 EDT 2007

Hi all!

The List module provides isPrefixOf, isSuffixOf, and --
recently -- isInfixOf, to check whether a list is a prefix,
a suffix, or an infix to another list.  Similarly, we have
inits and tails to obtain the prefixes and the suffixes of
a list, but there is no standard function that would return
a list of infixes.  For reasons of symmetry, perhaps it is
worth having a function in List returning, say, a list of
infixes of fixed length, such as e.g.,

infixes n as = map (take n) $ take (length as - n + 1)
(tails as)

Or, instead, there might be included a function that lists
infixes lexicographically  (map (tail . inits) . tails)
or perhaps otherwise, e.g. in the order of
lengths.  (In the latter case, the result might be a list of
lists of same-length infixes each.)

What do you think?


More information about the Haskell mailing list