Created
June 19, 2011 14:16
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
- 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