Last active
July 1, 2021 11:23
-
-
Save zeroflag/fc5ccedeff035c86dc02c7004c4e19c5 to your computer and use it in GitHub Desktop.
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
: unit 200 * ; | |
: ,, 1 unit ms ; | |
: _ 600 1 unit tone 1 unit ms ; | |
: ___ 600 3 unit tone 3 unit ms ; | |
: morse ( s -- ) | |
#[ | |
'A' { _ ,, ___ } | |
'B' { ___ ,, _ ,, _ ,, _ } | |
'C' { ___ ,, _ ,, ___ ,, _ } | |
'D' { ___ ,, _ ,, _ } | |
'E' { _ } | |
'F' { _ ,, _ ,, ___ ,, _ } | |
'G' { ___ ,, ___ ,, _ } | |
'H' { _ ,, _ ,, _ ,, _ } | |
'I' { _ ,, _ } | |
'J' { _ ,, ___ ,, ___ ,, ___ } | |
'K' { ___ ,, _ ,, ___ } | |
'L' { _ ,, ___ ,, _ ,, _ } | |
'M' { ___ ,, ___ } | |
'N' { ___ ,, _ } | |
'O' { ___ ,, ___ ,, ___ } | |
'P' { _ ,, ___ ,, ___ ,, _ } | |
'Q' { ___ ,, ___ ,, _ ,, ___ } | |
'R' { _ ,, ___ ,, _ } | |
'S' { _ ,, _ ,, _ } | |
'T' { ___ } | |
'U' { _ ,, _ ,, ___ } | |
'V' { _ ,, _ ,, _ ,, ___ } | |
'W' { _ ,, ___ ,, ___ } | |
'X' { ___ ,, _ ,, _ ,, ___ } | |
'Y' { ___ ,, _ ,, ___ ,, ___ } | |
'Z' { ___ ,, ___ ,, _ ,, _ } | |
'0' { ___ ,, ___ ,, ___ ,, ___ ,, ___ } | |
'1' { _ ,, ___ ,, ___ ,, ___ ,, ___ } | |
'2' { _ ,, _ ,, ___ ,, ___ ,, ___ } | |
'3' { _ ,, _ ,, _ ,, ___ ,, ___ } | |
'4' { _ ,, _ ,, _ ,, _ ,, ___ } | |
'5' { _ ,, _ ,, _ ,, _ ,, _ } | |
'6' { ___ ,, _ ,, _ ,, _ ,, _ } | |
'7' { ___ ,, ___ ,, _ ,, _ ,, _ } | |
'8' { ___ ,, ___ ,, ___ ,, _ ,, _ } | |
'9' { ___ ,, ___ ,, ___ ,, ___ ,, _ } | |
]# -> table | |
>str { | |
dup ' ' = if | |
drop 7 unit ms | |
else | |
table swap upper at | |
dup nil != if | |
yield 3 unit ms | |
else | |
'Unknown letter: ' . . | |
then | |
then | |
} each ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment