Skip to content

Instantly share code, notes, and snippets.

@danieldk
Created April 17, 2011 17:45
Show Gist options
  • Save danieldk/924272 to your computer and use it in GitHub Desktop.
Save danieldk/924272 to your computer and use it in GitHub Desktop.
Prefixes and suffixes
prefix :: Integer -> String -> [FeatureValue]
prefix n =
map (flip FeatureValue 1 . printf "prefix(%s)") . prefixes n
suffix :: Integer -> String -> [FeatureValue]
suffix n =
map (flip FeatureValue 1 . printf "suffix(%s)") . prefixes n . reverse
prefixes :: Integer -> String -> [String]
prefixes n word = do
n <- [1..n]
return $ genericTake n word
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment