Skip to main content
-1 and explain
Source Link
Adám
  • 31.1k
  • 3
  • 124
  • 287

APL (Dyalog Extended), 189 189 188 bytesSBCS

Full program. Prompts for the Morse code. Doesn't need the library. Requires ⎕IO←0

⌊⌂morse⍞⊂⍨∊1↑⍨¨1+,4⊤'⍳÷+≠í⍀÷<í∧○Ñ>å⌊⌂morse⍞⊂⍨∊1↑⍨¨1+4⊤'⍳÷+≠í⍀÷<í∧○Ñ>å/∧∨êî∘ß∧äñ⍀○≠è[*⌷∨[î≠∇è⊂Øî⊃⍀[⌷Éäï\∘∧↑æ=íå⌿∧∨ëäÖ⌿ê/≤⌊∘[Å↓Öï○+Ü÷≥↓≤≥>⌷∘á⊃↑Ü⍳⊣[⌿-Ø↑ä/∧∧≠≠Ñíí+ßÜ+-○é↓↓≥≥×∧↑**⍨↑}∧⍨≥ç⍀∧}×⍀Àëç⍀Ø⍨∧∘[×/∘Å∧~≥○ëâ⊂å∨≥Àäè?'⍳⍨125↓⎕AV

Try it online!Try it online!

⎕AV the Atomic Vector (the character set)

125↓ drop the first 125

''⍳⍨ the indices in that of these characters

4⊤ To-base four

1+ increment

This gives us the length of each Morse letter.

¨ for each of those lengths:

1↑⍨ take that many elements from 1, padding with zeros when needed

ϵnlist (flatten)

⊂⍨ use that as a mask indicating partition-beginnings to cut the following:

 prompt for Morse code

⌂morse convert from Morse code to uppercase text

 lowercase

APL (Dyalog Extended), 189 bytesSBCS

Full program. Prompts for the Morse code. Doesn't need the library.

⌊⌂morse⍞⊂⍨∊1↑⍨¨1+,4⊤'⍳÷+≠í⍀÷<í∧○Ñ>å/∧∨êî∘ß∧äñ⍀○≠è[*⌷∨[î≠∇è⊂Øî⊃⍀[⌷Éäï\∘∧↑æ=íå⌿∧∨ëäÖ⌿ê/≤⌊∘[Å↓Öï○+Ü÷≥↓≤≥>⌷∘á⊃↑Ü⍳⊣[⌿-Ø↑ä/∧∧≠≠Ñíí+ßÜ+-○é↓↓≥≥×∧↑**⍨↑}∧⍨≥ç⍀∧}×⍀Àëç⍀Ø⍨∧∘[×/∘Å∧~≥○ëâ⊂å∨≥Àäè?'⍳⍨125↓⎕AV

Try it online!

APL (Dyalog Extended), 189 188 bytesSBCS

Full program. Prompts for the Morse code. Doesn't need the library. Requires ⎕IO←0

⌊⌂morse⍞⊂⍨∊1↑⍨¨1+4⊤'⍳÷+≠í⍀÷<í∧○Ñ>å/∧∨êî∘ß∧äñ⍀○≠è[*⌷∨[î≠∇è⊂Øî⊃⍀[⌷Éäï\∘∧↑æ=íå⌿∧∨ëäÖ⌿ê/≤⌊∘[Å↓Öï○+Ü÷≥↓≤≥>⌷∘á⊃↑Ü⍳⊣[⌿-Ø↑ä/∧∧≠≠Ñíí+ßÜ+-○é↓↓≥≥×∧↑**⍨↑}∧⍨≥ç⍀∧}×⍀Àëç⍀Ø⍨∧∘[×/∘Å∧~≥○ëâ⊂å∨≥Àäè?'⍳⍨125↓⎕AV

Try it online!

⎕AV the Atomic Vector (the character set)

125↓ drop the first 125

''⍳⍨ the indices in that of these characters

4⊤ To-base four

1+ increment

This gives us the length of each Morse letter.

¨ for each of those lengths:

1↑⍨ take that many elements from 1, padding with zeros when needed

ϵnlist (flatten)

⊂⍨ use that as a mask indicating partition-beginnings to cut the following:

 prompt for Morse code

⌂morse convert from Morse code to uppercase text

 lowercase

Source Link
Adám
  • 31.1k
  • 3
  • 124
  • 287

APL (Dyalog Extended), 189 bytesSBCS

Full program. Prompts for the Morse code. Doesn't need the library.

⌊⌂morse⍞⊂⍨∊1↑⍨¨1+,4⊤'⍳÷+≠í⍀÷<í∧○Ñ>å/∧∨êî∘ß∧äñ⍀○≠è[*⌷∨[î≠∇è⊂Øî⊃⍀[⌷Éäï\∘∧↑æ=íå⌿∧∨ëäÖ⌿ê/≤⌊∘[Å↓Öï○+Ü÷≥↓≤≥>⌷∘á⊃↑Ü⍳⊣[⌿-Ø↑ä/∧∧≠≠Ñíí+ßÜ+-○é↓↓≥≥×∧↑**⍨↑}∧⍨≥ç⍀∧}×⍀Àëç⍀Ø⍨∧∘[×/∘Å∧~≥○ëâ⊂å∨≥Àäè?'⍳⍨125↓⎕AV

Try it online!