]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/morse/morse.factor
io.pathnames: go with / on windows for canonicalize-path
[factor.git] / extra / morse / morse.factor
old mode 100755 (executable)
new mode 100644 (file)
index 6803dfa..334ec90
@@ -1,9 +1,8 @@
 ! Copyright (C) 2007, 2008, 2009 Alex Chapman, 2009 Diego Martinelli
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors ascii assocs biassocs combinators hashtables
-kernel lists literals math namespaces make multiline openal
-openal.alut parser sequences splitting strings synth
-synth.buffers ;
+! See https://factorcode.org/license.txt for BSD license.
+USING: accessors ascii assocs biassocs combinators kernel
+literals math multiline namespaces openal openal.alut sequences
+splitting strings synth synth.buffers ;
 IN: morse
 
 ERROR: no-morse-ch ch ;
@@ -71,7 +70,7 @@ CONSTANT: morse-code-table $[
         { CHAR: + ".-.-."  }
         { CHAR: - "-....-" }
         { CHAR: _ "..--.-" }
-        { CHAR: " ".-..-." }
+        { CHAR: \" ".-..-." }
         { CHAR: $ "...-..-" }
         { CHAR: @ ".--.-." }
         { CHAR: \s "/" }
@@ -83,39 +82,39 @@ CONSTANT: morse-code-table $[
 
 : morse>ch ( str -- ch )
     morse-code-table value-at char-gap-char or ;
-    
+
 <PRIVATE
-    
+
 : word>morse ( str -- morse )
-    [ ch>morse ] { } map-as " " join ;
+    [ ch>morse ] { } map-as join-words ;
 
 : sentence>morse ( str -- morse )
-    " " split [ word>morse ] map " / " join ;
-    
+    split-words [ word>morse ] map " / " join ;
+
 : trim-blanks ( str -- newstr )
     [ blank? ] trim ; inline
 
 : morse>word ( morse -- str )
-    " " split [ morse>ch ] "" map-as ;
+    split-words [ morse>ch ] "" map-as ;
 
 : morse>sentence ( morse -- sentence )
-    "/" split [ trim-blanks morse>word ] map " " join ;
+    "/" split [ trim-blanks morse>word ] map join-words ;
 
 : replace-underscores ( str -- str' )
     [ dup CHAR: _ = [ drop CHAR: - ] when ] map ;
 
 PRIVATE>
-    
+
 : >morse ( str -- newstr )
     trim-blanks sentence>morse ;
-    
+
 : morse> ( morse -- plain )
     replace-underscores morse>sentence ;
 
-SYNTAX: [MORSE "MORSE]" parse-multiline-string morse> suffix! ; 
-    
+SYNTAX: [MORSE "MORSE]" parse-multiline-string morse> suffix! ;
+
 <PRIVATE
-    
+
 SYMBOLS: source dot-buffer dash-buffer intra-char-gap-buffer letter-gap-buffer ;
 
 : queue ( symbol -- )
@@ -129,7 +128,7 @@ SYMBOLS: source dot-buffer dash-buffer intra-char-gap-buffer letter-gap-buffer ;
 CONSTANT: beep-freq 880
 
 : <morse-buffer> ( -- buffer )
-    half-sample-freq <8bit-mono-buffer> ;
+    half-sample-freq <8-bit-mono-buffer> ;
 
 : sine-buffer ( seconds -- id )
     beep-freq swap <morse-buffer> >sine-wave-buffer