Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Transform Morse code data model to on/off states with relative durations
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