Morse

new topic     » topic index » view thread      » older message » newer message

Anyone want to post a smaller, more efficient and/or more 'Euphoric' way to do this?

 
constant morse =  
{"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--..", 
 "1.----","2..---","3...--","4....-","5.....", 
 "6-....","7--...","8---..","9----.","0-----", 
 "..-.-.-","\\--..--","  "} 
 
constant EOM = ".-.-." 
 
include std/console.e   -- for display  
include std/text.e      -- for lower  
include std/sequence.e  -- for vslice 
include std/search.e    -- for lookup  
 
integer key = 0 
object index = vslice(morse,1) 
object code 
 
while key != 27 do 
    key = lower(wait_key()) 
    if key = 27 then exit 
    else 
        code = lookup(key,index,morse,"?") 
        display(code[2..$]&' ',,0) 
    end if 
end while 
 
display(EOM) 
new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu