Soundex: Difference between revisions

m
→‎{{header|Sidef}}: minor improvement: now soundex() function can take an optional argument which specifies the length of the numbers
m (Added Sidef language)
m (→‎{{header|Sidef}}: minor improvement: now soundex() function can take an optional argument which specifies the length of the numbers)
Line 2,535:
 
=={{header|Sidef}}==
<lang ruby>func soundex(word, length=4) {
 
# Uppercase the argument passed in to normalize it
Line 2,565:
word ~~ /^\d+\z/ ? (
var num = word.to_f;
num * (10**(3length-1 - num.log10.int)) -> to_i.to_s
) : ('0' * 4length));
 
# create the sdxValue with the leading firstLetter
Line 2,592:
 
sndx.keys.sort.each { |name|
var findSdx = soundex(name, 4); # calls function w/param of name
say "The soundex for #{name} should be #{sndx[name]} and is #{findSdx}";
if (findSdx != sndx[name]) {
2,747

edits