module NGramCrackers.ListManipulation
(
 getNSeqFromList,
 intToList
) where

import Data.List
import Data.Char (isAlpha)

getNGramsFromList :: Int -> [String] -> [[String]]
getNGramsFromList n wordList = getNSeqFromList n wordList 

{-| Return only alphabetic characters from a string and return the
    result as a string. Output of this function may need processing
    into a list, tuple, etc. -}
getAlphasOnly :: [Char] -> [Char]
getAlphasOnly = (unwords . map (filter (isAlpha)) . words)

{-| Function creates a list of lists of n length -}
getNSeqFromList :: Int -> [a] -> [[a]]
getNSeqFromList n [] = []
getNSeqFromList n (x:xs) 
    | length (x:xs) >= n = take n (x:xs) : getNSeqFromList n xs
    | otherwise = []

intToList :: Integer -> [Int]
intToList i = map read $ words (intersperse ' ' $ show i) :: [Int]

module ListManipulation
(
  getNSeqFromList
, intToList
) where

import Data.List

{-| Function creates a list of lists of n length -}
getNSeqFromList :: Int -> [a] -> [[a]]
getNSeqFromList n [] = []
getNSeqFromList n (x:xs) 
    | length (x:xs) >= n = take n (x:xs) : getNSeqFromList n xs
    | otherwise = []

intToList :: Integer -> [Int]
intToList i = map read $ words (intersperse ' ' $ show i) :: [Int]

Move n-gram functions to separate module
Move n-gram functions to separate module
