Skip to content

Instantly share code, notes, and snippets.

@ploeh
Created January 28, 2018 19:32
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 ploeh/4bfa18c0a23387f2396f1d1aac06cc0f to your computer and use it in GitHub Desktop.
Save ploeh/4bfa18c0a23387f2396f1d1aac06cc0f to your computer and use it in GitHub Desktop.
module RadioCode where
import Control.Arrow
import Data.Char
import Data.List
import Data.Maybe
icao :: [(Char, String)]
icao =
(head &&& delete ',')
<$> words "Alfa, Bravo, Charlie, Delta, Echo, Foxtrot, Golf, Hotel, India, Juliett, Kilo, Lima, Mike, November, Oscar, Papa, Quebec, Romeo, Sierra, Tango, Uniform, Victor, Whiskey, X-ray, Yankee, Zulu"
radioCode :: String -> String
radioCode = unwords . catMaybes . fmap ((`lookup` icao) . toUpper)
message :: String
message = radioCode "If you can read this"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment