Soundex: Difference between revisions

1,864 bytes added ,  3 months ago
m
m (→‎{{header|Wren}}: Minor tidy)
 
(3 intermediate revisions by 3 users not shown)
Line 1,727:
T522
</pre>
 
=={{header|EasyLang}}==
{{trans|Java}}
<syntaxhighlight>
trans$ = "01230120022455012623010202"
func$ code c$ .
c = strcode c$ - 64
if c > 26
c -= 32
.
return substr trans$ c 1
.
func$ soundex s$ .
code$ = substr s$ 1 1
prev$ = code code$
for i = 2 to len s$
cur$ = code substr s$ i 1
if cur$ <> "" and cur$ <> "0" and cur$ <> prev$
code$ &= cur$
.
prev$ = cur$
.
return substr code$ & "0000" 1 4
.
for v$ in [ "Soundex" "Example" "Sownteks" "Ekzampul" ]
print soundex v$
.
</syntaxhighlight>
 
 
=={{header|Elixir}}==
Line 4,512 ⟶ 4,541:
"Soundex" S532
"Example" E251
</pre>
 
=={{header|RPL}}==
≪ "a123e12Xi22455o12623u1X2X2" "123456" → name table codes
≪ name 1 1 SUB ""
1 name SIZE '''FOR''' j
name j DUP SUB NUM
R→B #DFh AND B→R
'''IF''' 65 OVER ≤ OVER 90 ≤ AND '''THEN'''
table SWAP 64 - DUP SUB
'''IF''' DUP "X" ≠ '''THEN''' + '''ELSE''' DROP '''END'''
'''ELSE''' DROP '''END'''
'''NEXT'''
'name' STO
2 name SIZE '''FOR''' j
name j DUP SUB
'''IF''' codes OVER POS OVER name j 1 - DUP SUB ≠ AND '''THEN''' + '''ELSE''' DROP '''END'''
'''NEXT'''
"000" + 1 4 SUB
≫ ≫ '<span style="color:blue">SOUNDX</span>' STO
 
French Soundex code can be generated by modifying the table to "a123e97Xi72455o12683u9X8y8" and the codes to "123456789"
≪ { "Ashcraft" "Ashcroft" "Gauss" "Ghosh" "Ghosn" "Hilbert" "Heilbronn" "Lee" "Lloyd" "Moses" "Pfister" "Robert" "Rupert" "Rubin" "Tymczak" "Soundex" "Example" } { }
1 3 PICK SIZE '''FOR''' j
OVER j GET <span style="color:blue">SOUNDX</span> + '''NEXT'''
SWAP DROP
≫ '<span style="color:blue">TESTS</span>' STO
{{out}}
<pre>
1: { { "A261" "A261" "G200" "G200" "G250" "H416" "H416" "L000" "L300" "M220" "P236" "R163" "R163" "R150" "T522" "S532" "E251" } }
</pre>
 
Line 4,655 ⟶ 4,714:
}
if a.len() < 4 {
for _ in 0..(54 - a.len()) {
a.push('0');
}
Line 5,678 ⟶ 5,737:
{{libheader|Wren-str}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./str" for Char
import "./fmt" for Fmt
 
var getCode = Fn.new { |c|
9,483

edits