{
   "labels" : [
      "code",
      "disquiet junto",
      "disquiet",
      "junto",
      "morse"
   ],
   "is_private" : null,
   "id" : "1-4RQ",
   "code" : "(\r\n/*\r\n*  MORSE by Jonathan Siemasko\r\n*  http://www.schemawound.com/\r\n*\r\n*  Function to take a string and convert it to morse code.\r\n*  Handles a-z, A-Z and 0-9\r\n*  Parameters allow you to adjust the space between letters and words\r\n*  These parameters default to international morse code as shown on http://en.wikipedia.org/wiki/Morse_code\r\n*\r\n*  NOTE: wordSpace must be equal to or greater than letterSpace.\r\n*\r\n*  Created to assist my work on DISQUIET JUNTO PROJECT 0050: -…….–.-..-…-\r\n*  More Info: http://disquiet.com/2012/12/13/disquiet0050-morsebeat/\r\n*/\r\nvar morse = {|inString, spaceBetweenLetters = 3, spaceBetweenWords = 7|\r\n\tvar outString = \"\"; //String that will be output\r\n\tvar letterSpace = \"\"; //String representing space between letters\r\n\tvar wordSpace = \"\"; //String representing space between words\r\n\tvar charToMorse;\r\n\r\n\t//Fill letterSpace per number specified in spaceBetweenLetters\r\n\t(spaceBetweenLetters - 1).do{letterSpace = letterSpace ++ \" \"};\r\n\r\n\t//Fill wordSpace per number specified in spaceBetweenWords.\r\n\t//wordSpace reduced by the size of letterSpace to account for that will occur before it.\r\n\t(spaceBetweenWords - spaceBetweenLetters).do{wordSpace = wordSpace ++ \" \"};\r\n\r\n\t//Function to convert a single character to morse code\r\n\tcharToMorse = {|inChar|\r\n\t\tswitch(inChar,\r\n\t\t\t//Alpha\r\n\t\t\t$A, {\".-\"},     $B, {\"-...\"},   $C, {\"-.-.\"},   $D, {\"-..\"},    $E, {\".\"},      $F, {\"..-.\"},\r\n\t\t\t$G, {\"--.\"},    $H, {\"....\"},   $I, {\"..\"},     $J, {\".---\"},   $K, {\"-.-\"},    $L, {\".-..\"},\r\n\t\t\t$M, {\"--\"},     $N, {\"-.\"},     $O, {\"---\"},    $P, {\".--.\"},   $Q, {\"--.-\"},   $R, {\".-.\"},\r\n\t\t\t$S, {\"...\"},    $T, {\"-\"},      $U, {\"..-\"},    $V, {\"...-\"},   $W, {\".--\"},    $X, {\"-..-\"},\r\n\t\t\t$Y, {\"-.--\"},   $Z, {\"--..\"},\r\n\t\t\t//Numeric\r\n\t\t\t$1, {\".----\"},  $2, {\"..---\"},  $3, {\"...--\"},  $4, {\"....-\"},  $5, {\".....\"},  $6, {\"-....\"},\r\n\t\t\t$7, {\"--...\"},  $8, {\"---..\"},  $9, {\"----.\"},  $0, {\"-----\"},\r\n\t\t\t//Special Handling\r\n\t\t\t$ , {wordSpace}\r\n\t\t);\r\n\t};\r\n\r\n\t//Take the input string, convert to uppercase and convert one letter at a time.  Add letterSpace between letters\r\n\tinString.toUpper.do{|char, i|\r\n\t\tvar isFinalChar = (i != (inString.size - 1));\r\n\t\tvar isWordSpace = (char != $ );\r\n\t\toutString = outString ++ charToMorse.(char);\r\n\t\t//Include letterSpace after each character except wordSpaces and the final letter.\r\n\t\tif(isFinalChar && isWordSpace, {outString = outString + letterSpace});\r\n\t};\r\n\toutString;\r\n};\r\n\r\n//Test it out\r\nmorse.(\"Hello World\");\r\n)",
   "author" : "Schemawound",
   "name" : "Morse",
   "description" : "MORSE by Jonathan Siemasko\r\n\r\n[http://www.schemawound.com/](http://www.schemawound.com/)\r\n\r\n\r\nFunction to take a string and convert it to morse code.\r\n\r\nHandles a-z, A-Z and 0-9\r\n\r\nParameters allow you to adjust the space between letters and words\r\n\r\nThese parameters default to international morse code as shown on [http://en.wikipedia.org/wiki/Morse_code](http://en.wikipedia.org/wiki/Morse_code)\r\n\r\n\r\nNOTE: wordSpace must be equal to or greater than letterSpace.\r\n\r\n\r\nCreated to assist my work on [DISQUIET JUNTO PROJECT 0050: -…….–.-..-…-](http://disquiet.com/2012/12/13/disquiet0050-morsebeat/)",
   "ancestor_list" : []
}
