Hi all! The List module provides isPrefixOf, isSuffixOf, and -- since 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 all infixes lexicographically (map (tail . inits) . tails) or perhaps otherwise, e.g. in the order of increasing/decreasing lengths. (In the latter case, the result might be a list of lists of same-length infixes each.) What do you think? Regards, Boyko _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell