Soundex: Difference between revisions

Added 11l
(Added Wren)
(Added 11l)
Line 12:
* If "H" or "W" separate two consonants that have the same soundex code, the consonant to the right of the vowel is not coded. Example: Ashcraft is coded A-261 (A, 2 for the S, C ignored, 6 for the R, 1 for the F). It is not coded A-226.
<br><br>
 
=={{header|11l}}==
{{trans|Java}}
 
<lang 11l>V inv_code = [
‘1’ = [‘B’, ‘F’, ‘P’, ‘V’],
‘2’ = [‘C’, ‘G’, ‘J’, ‘K’, ‘Q’, ‘S’, ‘X’, ‘Z’],
‘3’ = [‘D’, ‘T’],
‘4’ = [‘L’],
‘5’ = [‘M’, ‘N’],
‘6’ = [‘R’]
]
 
[Char = Char] _code
L(k, arr) inv_code
L(el) arr
_code[el] = k
 
F soundex(s)
V code = String(s[0].uppercase())
V previous = :_code.get(s[0].uppercase(), Char("\0"))
 
L(c) s[1..]
V current = :_code.get(c.uppercase(), Char("\0"))
I current != "\0" & current != previous
code ‘’= current
previous = current
 
R (code‘0000’)[0.<4]
 
print(soundex(‘Soundex’))
print(soundex(‘Example’))
print(soundex(‘Sownteks’))
print(soundex(‘Ekzampul’))</lang>
 
{{out}}
<pre>
S532
E251
S532
E251
</pre>
 
=={{header|360 Assembly}}==
1,480

edits