Skip to content

Instantly share code, notes, and snippets.

@axelerator
Created June 19, 2011 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axelerator/1034333 to your computer and use it in GitHub Desktop.
Save axelerator/1034333 to your computer and use it in GitHub Desktop.
Small programm to combine syllables, where some syllables are used only as suffix/prefix
{-
- Small programm to combine syllables, where some syllables
- are used only as suffix/prefix
- 1. Install: GHC
- 2. Compile: ghc -o namevote namevoting.hs
- 3. Run: namevote '[Pre "neo", Suf "master", Pre "turbo", Uni "leo", Suf "3000"]'
-}
module Main where
import System.Environment
data WordType = Pre String | Suf String | Uni String
deriving Read
buildFixes x = foldr splt ([], []) x
splt (Pre s) (ps, ss) = (s:ps, ss)
splt (Suf s) (ps, ss) = ( ps, s:ss)
splt (Uni s) (ps, ss) = (s:ps, s:ss)
mult (ps, ss) = [ p ++ s | p <- ps, s <- ss, p /= s]
main = getArgs >>= (putStrLn . show . mult . buildFixes . read . head)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment