morse: add a default speed to play at

db4
Alex Chapman 2008-05-01 11:49:55 +10:00
parent ce2412c4c8
commit b729186986
2 changed files with 4 additions and 2 deletions

View File

@ -10,4 +10,4 @@ USING: arrays morse strings tools.test ;
[ "morse code" ] [ "-- --- .-. ... . / -.-. --- -.. ." morse> ] unit-test
[ "hello, world!" ] [ "Hello, World!" >morse morse> ] unit-test
[ ] [ "sos" 0.075 play-as-morse ] unit-test
[ ] [ "Factor rocks!" 0.05 play-as-morse ] unit-test
[ ] [ "Factor rocks!" play-as-morse ] unit-test

View File

@ -167,8 +167,10 @@ SYMBOLS: source dot-buffer dash-buffer intra-char-gap-buffer letter-gap-buffer ;
PRIVATE>
: play-as-morse ( str unit-length -- )
: play-as-morse* ( str unit-length -- )
[
[ letter-gap ] [ ch>morse play-char ] interleave
] swap playing-morse ;
: play-as-morse ( str -- )
0.05 play-as-morse* ;