Last active
July 19, 2016 04:23
-
-
Save ijoshsmith/f40797005931cb6b253af782b947cb74 to your computer and use it in GitHub Desktop.
Transform Morse code data model to on/off states with relative durations
This file contains hidden or 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
enum TransmissionState { | |
typealias RelativeDuration = Int | |
case On(RelativeDuration) | |
case Off(RelativeDuration) | |
static func createStates(from encodedMessage: EncodedMessage) | |
-> [TransmissionState] { | |
let transformation = MorseTransformation( | |
dot: TransmissionState.On(1), | |
dash: TransmissionState.On(3), | |
markSeparator: TransmissionState.Off(1), | |
symbolSeparator: TransmissionState.Off(3), | |
termSeparator: TransmissionState.Off(7)) | |
return transformation.apply(to: encodedMessage) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment