<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Soundex</title>
	<atom:link href="http://programmingpraxis.com/2010/02/16/soundex/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmingpraxis.com/2010/02/16/soundex/</link>
	<description>A collection of etudes, updated weekly, for the education and enjoyment of the savvy programmer</description>
	<lastBuildDate>Mon, 28 May 2012 03:30:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Vikas Tandi</title>
		<link>http://programmingpraxis.com/2010/02/16/soundex/#comment-2997</link>
		<dc:creator><![CDATA[Vikas Tandi]]></dc:creator>
		<pubDate>Fri, 06 May 2011 17:22:52 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1995#comment-2997</guid>
		<description><![CDATA[My implementation in C
[sourcecode lang=&quot;cpp&quot;]
#include &lt;string.h&gt;
#include &lt;ctype.h&gt;

static void squeeze(char *s, char *t);
static void assign_code(char *s);
static void remove_adjacent_code(char *s);
static void remove_initial_letters(char *s);

void soundex_code(char *name)
{
	int len;
	char *s = &quot;hw&quot;;
	char *q = &quot;aeiouy&quot;;

	remove_initial_letters(name);
	/* convert to code */
	assign_code(name+1);

	/* drop all occurrences of h, w except first letter */
	squeeze(name+1, s);

	/* remove adjacent code */
	remove_adjacent_code(name);

	/* drop all occurrences of a, e, i, o, u, y except first letter */
	squeeze(name+1, q);

	if((len = strlen(name)) &gt; 4)
		name[4] = &#039;&#092;&#048;&#039;;

	if(len &lt; 4)
	{
		while(len &lt; 4)
			name[len++] = &#039;0&#039;;

		name[len] = &#039;&#092;&#048;&#039;;
	}
}

static void remove_initial_letters(char *s)
{
	char *p;

	for(p = s+1; tolower(*p) == tolower(*s); p++);

	for(; *p != &#039;&#092;&#048;&#039;; p++)
		*++s = *p;

	*++s = &#039;&#092;&#048;&#039;;
}

static void assign_code(char *s)
{
	char c;
	for(; *s != &#039;&#092;&#048;&#039;; s++)
	{
		c = tolower(*s);

		if(c == &#039;b&#039; &#124;&#124; c == &#039;f&#039; &#124;&#124; c == &#039;p&#039; &#124;&#124; c == &#039;v&#039;)
			*s = &#039;1&#039;;
		else if(c == &#039;c&#039; &#124;&#124; c == &#039;g&#039; &#124;&#124; c == &#039;j&#039; &#124;&#124; c == &#039;k&#039; 
				&#124;&#124; c == &#039;q&#039; &#124;&#124; c == &#039;s&#039; &#124;&#124; c == &#039;x&#039; &#124;&#124; c == &#039;z&#039;)
			*s = &#039;2&#039;;
		else if(c == &#039;d&#039; &#124;&#124; c == &#039;t&#039;)
			*s = &#039;3&#039;;
		else if(c == &#039;l&#039;)
			*s = &#039;4&#039;;
		else if(c == &#039;m&#039; &#124;&#124; c == &#039;n&#039;)
			*s = &#039;5&#039;;
		else if(c == &#039;r&#039;)
			*s = &#039;6&#039;;
	}
}

static void remove_adjacent_code(char *s)
{
	char *p;

	for(p = s+1; *p != &#039;&#092;&#048;&#039;; p++)
	{
		if(tolower(*s) == tolower(*p))
			continue;

		*++s = *p;
	}
	*++s = &#039;&#092;&#048;&#039;;
}

static void squeeze(char *s, char *t)
{
	char *p, *q;

	for(p = s; *p != &#039;&#092;&#048;&#039;; p++)
	{
		for(q = t; *q != &#039;&#092;&#048;&#039; &amp;&amp; tolower(*p) != tolower(*q); q++);
		if(*q == &#039;&#092;&#048;&#039;)
			*s++ = *p;
	}
	*s = &#039;&#092;&#048;&#039;;
}
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>My implementation in C</p>
<pre class="brush: cpp;">
#include &lt;string.h&gt;
#include &lt;ctype.h&gt;

static void squeeze(char *s, char *t);
static void assign_code(char *s);
static void remove_adjacent_code(char *s);
static void remove_initial_letters(char *s);

void soundex_code(char *name)
{
	int len;
	char *s = &quot;hw&quot;;
	char *q = &quot;aeiouy&quot;;

	remove_initial_letters(name);
	/* convert to code */
	assign_code(name+1);

	/* drop all occurrences of h, w except first letter */
	squeeze(name+1, s);

	/* remove adjacent code */
	remove_adjacent_code(name);

	/* drop all occurrences of a, e, i, o, u, y except first letter */
	squeeze(name+1, q);

	if((len = strlen(name)) &gt; 4)
		name[4] = '&#092;&#048;';

	if(len &lt; 4)
	{
		while(len &lt; 4)
			name[len++] = '0';

		name[len] = '&#092;&#048;';
	}
}

static void remove_initial_letters(char *s)
{
	char *p;

	for(p = s+1; tolower(*p) == tolower(*s); p++);

	for(; *p != '&#092;&#048;'; p++)
		*++s = *p;

	*++s = '&#092;&#048;';
}

static void assign_code(char *s)
{
	char c;
	for(; *s != '&#092;&#048;'; s++)
	{
		c = tolower(*s);

		if(c == 'b' || c == 'f' || c == 'p' || c == 'v')
			*s = '1';
		else if(c == 'c' || c == 'g' || c == 'j' || c == 'k' 
				|| c == 'q' || c == 's' || c == 'x' || c == 'z')
			*s = '2';
		else if(c == 'd' || c == 't')
			*s = '3';
		else if(c == 'l')
			*s = '4';
		else if(c == 'm' || c == 'n')
			*s = '5';
		else if(c == 'r')
			*s = '6';
	}
}

static void remove_adjacent_code(char *s)
{
	char *p;

	for(p = s+1; *p != '&#092;&#048;'; p++)
	{
		if(tolower(*s) == tolower(*p))
			continue;

		*++s = *p;
	}
	*++s = '&#092;&#048;';
}

static void squeeze(char *s, char *t)
{
	char *p, *q;

	for(p = s; *p != '&#092;&#048;'; p++)
	{
		for(q = t; *q != '&#092;&#048;' &amp;&amp; tolower(*p) != tolower(*q); q++);
		if(*q == '&#092;&#048;')
			*s++ = *p;
	}
	*s = '&#092;&#048;';
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://programmingpraxis.com/2010/02/16/soundex/#comment-1177</link>
		<dc:creator><![CDATA[Mike]]></dc:creator>
		<pubDate>Tue, 20 Apr 2010 17:34:13 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1995#comment-1177</guid>
		<description><![CDATA[Python version.

_code is a mapping of letter to soundex code or &quot;&quot; for letters in the first group.

The algorithm doesn&#039;t say how to handle punctuation (spaces, hyphens, apostrophes), so I strip them.

groupby processes its first argument to find groups of items having the same key, as determined by the second argument.  _code.get does a dictionary lookup, returning the soundex code.  So, groupby returns (k,v)-pairs, where k is a soundex code, and v is a group of adjacent letters having that code. The join concatentates the soundex codes, skipping the first.

[sourcecode lang=&quot;python&quot;]
from itertools import groupby

_groups = &quot;AEHIOUWY BFPV CGJKQSXZ DT L MN R&quot;.split()
_code = dict( (ltr, str(n or &#039;&#039;)) for n,s in enumerate(_groups) for ltr in s )

def soundex( name ):
    uname = name.upper().replace(&quot; &#039;-&quot;, &quot;&quot;)
    tail = &#039;&#039;.join( [ k for k,_ in groupby(uname, _code.get) ][1:] )
    return (uname[0] + tail + &#039;000&#039;)[:4]


#test from knuth
namelists = [&quot;Euler  Gauss Hilbert   Knuth Lloyd Lukasiewicz&quot;,
             &quot;Ellery Ghosh Heilbronn Kant  Ladd  Lissajous&quot;  ]
result =     &quot;E460   G200  H416      K530  L300  L222&quot;.split()

for names in namelists:
    assert map( soundex, names.split() ) == result
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>Python version.</p>
<p>_code is a mapping of letter to soundex code or &#8220;&#8221; for letters in the first group.</p>
<p>The algorithm doesn&#8217;t say how to handle punctuation (spaces, hyphens, apostrophes), so I strip them.</p>
<p>groupby processes its first argument to find groups of items having the same key, as determined by the second argument.  _code.get does a dictionary lookup, returning the soundex code.  So, groupby returns (k,v)-pairs, where k is a soundex code, and v is a group of adjacent letters having that code. The join concatentates the soundex codes, skipping the first.</p>
<pre class="brush: python;">
from itertools import groupby

_groups = &quot;AEHIOUWY BFPV CGJKQSXZ DT L MN R&quot;.split()
_code = dict( (ltr, str(n or '')) for n,s in enumerate(_groups) for ltr in s )

def soundex( name ):
    uname = name.upper().replace(&quot; '-&quot;, &quot;&quot;)
    tail = ''.join( [ k for k,_ in groupby(uname, _code.get) ][1:] )
    return (uname[0] + tail + '000')[:4]


#test from knuth
namelists = [&quot;Euler  Gauss Hilbert   Knuth Lloyd Lukasiewicz&quot;,
             &quot;Ellery Ghosh Heilbronn Kant  Ladd  Lissajous&quot;  ]
result =     &quot;E460   G200  H416      K530  L300  L222&quot;.split()

for names in namelists:
    assert map( soundex, names.split() ) == result
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://programmingpraxis.com/2010/02/16/soundex/#comment-1116</link>
		<dc:creator><![CDATA[Scott]]></dc:creator>
		<pubDate>Mon, 22 Mar 2010 03:14:02 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1995#comment-1116</guid>
		<description><![CDATA[C#, I&#039;m sure it could be faster but it works nicely.

using System;
using System.Collections.Generic;

namespace Soundex
{
    class Program
    {
        static void Main()
        {
            string str = &quot;Soundex&quot;;
            Console.WriteLine(str.Soundex());
            Console.ReadKey();
        }
    }

    static class Extensions
    {
        public static string Soundex(this string str)
        {
            char f = &#039;&#039;;
            char last = &#039;&#039;;
            List num;

            var chr = new List(
                str.ToLower().ToCharArray()
            ).FindAll(c =&gt; 
                c &gt;= &#039;a&#039; &amp;&amp; c &lt;= &#039;z&#039; &amp;&amp; c != &#039;a&#039; &amp;&amp; c != &#039;e&#039; &amp;&amp; c != &#039;h&#039; &amp;&amp; 
                c != &#039;i&#039; &amp;&amp; c != &#039;o&#039; &amp;&amp; c != &#039;u&#039; &amp;&amp; c != &#039;w&#039; &amp;&amp; c != &#039;y&#039;
            );

            f = chr[0];
            chr.RemoveAt(0);

            num = new List(chr.Count);

            chr.ForEach(
                delegate(char c)
                {
                    if (num.Count &lt; 3 &amp;&amp; c != last)
                    {
                        switch (c)
                        {
                            case &#039;b&#039;: case &#039;f&#039;:
                            case &#039;p&#039;: case &#039;v&#039;:
                                num.Add(&#039;1&#039;);
                                break;
                            case &#039;c&#039;: case &#039;g&#039;:
                            case &#039;j&#039;: case &#039;k&#039;:
                            case &#039;q&#039;: case &#039;s&#039;:
                            case &#039;x&#039;: case &#039;z&#039;:
                                num.Add(&#039;2&#039;);
                                break;
                            case &#039;d&#039;: case &#039;t&#039;:
                                num.Add(&#039;3&#039;);
                                break;
                            case &#039;l&#039;:
                                num.Add(&#039;4&#039;);
                                break;
                            case &#039;m&#039;: case &#039;n&#039;:
                                num.Add(&#039;5&#039;);
                                break;
                            default:
                                num.Add(&#039;6&#039;);
                                break;
                        }
                    }
                    last = c;
                }
            );

            return ((f &lt; 95) ? f : (char)(f - 32)) + new string(num.ToArray()).PadRight(3, &#039;0&#039;);
        }
    }
}]]></description>
		<content:encoded><![CDATA[<p>C#, I&#8217;m sure it could be faster but it works nicely.</p>
<p>using System;<br />
using System.Collections.Generic;</p>
<p>namespace Soundex<br />
{<br />
    class Program<br />
    {<br />
        static void Main()<br />
        {<br />
            string str = &#8220;Soundex&#8221;;<br />
            Console.WriteLine(str.Soundex());<br />
            Console.ReadKey();<br />
        }<br />
    }</p>
<p>    static class Extensions<br />
    {<br />
        public static string Soundex(this string str)<br />
        {<br />
            char f = &#8221;;<br />
            char last = &#8221;;<br />
            List num;</p>
<p>            var chr = new List(<br />
                str.ToLower().ToCharArray()<br />
            ).FindAll(c =&gt;<br />
                c &gt;= &#8216;a&#8217; &amp;&amp; c &lt;= &#039;z&#039; &amp;&amp; c != &#039;a&#039; &amp;&amp; c != &#039;e&#039; &amp;&amp; c != &#039;h&#039; &amp;&amp;<br />
                c != &#039;i&#039; &amp;&amp; c != &#039;o&#039; &amp;&amp; c != &#039;u&#039; &amp;&amp; c != &#039;w&#039; &amp;&amp; c != &#039;y&#039;<br />
            );</p>
<p>            f = chr[0];<br />
            chr.RemoveAt(0);</p>
<p>            num = new List(chr.Count);</p>
<p>            chr.ForEach(<br />
                delegate(char c)<br />
                {<br />
                    if (num.Count &lt; 3 &amp;&amp; c != last)<br />
                    {<br />
                        switch (c)<br />
                        {<br />
                            case &#039;b&#039;: case &#039;f&#039;:<br />
                            case &#039;p&#039;: case &#039;v&#039;:<br />
                                num.Add(&#039;1&#039;);<br />
                                break;<br />
                            case &#039;c&#039;: case &#039;g&#039;:<br />
                            case &#039;j&#039;: case &#039;k&#039;:<br />
                            case &#039;q&#039;: case &#039;s&#039;:<br />
                            case &#039;x&#039;: case &#039;z&#039;:<br />
                                num.Add(&#039;2&#039;);<br />
                                break;<br />
                            case &#039;d&#039;: case &#039;t&#039;:<br />
                                num.Add(&#039;3&#039;);<br />
                                break;<br />
                            case &#039;l&#039;:<br />
                                num.Add(&#039;4&#039;);<br />
                                break;<br />
                            case &#039;m&#039;: case &#039;n&#039;:<br />
                                num.Add(&#039;5&#039;);<br />
                                break;<br />
                            default:<br />
                                num.Add(&#039;6&#039;);<br />
                                break;<br />
                        }<br />
                    }<br />
                    last = c;<br />
                }<br />
            );</p>
<p>            return ((f &lt; 95) ? f : (char)(f &#8211; 32)) + new string(num.ToArray()).PadRight(3, &#039;0&#039;);<br />
        }<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: targ</title>
		<link>http://programmingpraxis.com/2010/02/16/soundex/#comment-1042</link>
		<dc:creator><![CDATA[targ]]></dc:creator>
		<pubDate>Tue, 23 Feb 2010 10:32:02 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1995#comment-1042</guid>
		<description><![CDATA[http://pastebin.com/bgDF5adL]]></description>
		<content:encoded><![CDATA[<p><a href="http://pastebin.com/bgDF5adL" rel="nofollow">http://pastebin.com/bgDF5adL</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://programmingpraxis.com/2010/02/16/soundex/#comment-1041</link>
		<dc:creator><![CDATA[Dave]]></dc:creator>
		<pubDate>Mon, 22 Feb 2010 22:50:16 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1995#comment-1041</guid>
		<description><![CDATA[[sourcecode language=&quot;ruby&quot;]
class Soundex
  def self.parse(str)
    input = str.dup.gsub(/(\w)(\1)/i, &#039;\1&#039;).gsub(/(?!\A)[a&#124;e&#124;i&#124;o&#124;u&#124;w&#124;y&#124;h]/i, &#039;&#039;)
    input[0].chr + Array.new(3) { &#124;i&#124; input[1..-1][i] &#124;&#124; 48 }.map do &#124;ch&#124;
      %w(0 bfpv cgjkqsxz dt l mn r).each_with_index.detect { &#124;s&#124; s.first.include? ch.chr }.last
    end.join
  end
end
[/sourcecode]

That Haskell up there makes me want to coo :)]]></description>
		<content:encoded><![CDATA[<pre class="brush: ruby;">
class Soundex
  def self.parse(str)
    input = str.dup.gsub(/(\w)(\1)/i, '\1').gsub(/(?!\A)[a|e|i|o|u|w|y|h]/i, '')
    input[0].chr + Array.new(3) { |i| input[1..-1][i] || 48 }.map do |ch|
      %w(0 bfpv cgjkqsxz dt l mn r).each_with_index.detect { |s| s.first.include? ch.chr }.last
    end.join
  end
end
</pre>
<p>That Haskell up there makes me want to coo :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Programming Praxis &#8211; Soundex &#171; Bonsai Code</title>
		<link>http://programmingpraxis.com/2010/02/16/soundex/#comment-1024</link>
		<dc:creator><![CDATA[Programming Praxis &#8211; Soundex &#171; Bonsai Code]]></dc:creator>
		<pubDate>Wed, 17 Feb 2010 08:24:52 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1995#comment-1024</guid>
		<description><![CDATA[[...] Praxis &#8211;&#160;Soundex By Remco Niemeijer  In today&#8217;s Programming Praxis exercise we have to implement the soundex algorithm for encoding people&#8217;s [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Praxis &#8211;&nbsp;Soundex By Remco Niemeijer  In today&#8217;s Programming Praxis exercise we have to implement the soundex algorithm for encoding people&#8217;s [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: harry</title>
		<link>http://programmingpraxis.com/2010/02/16/soundex/#comment-1022</link>
		<dc:creator><![CDATA[harry]]></dc:creator>
		<pubDate>Wed, 17 Feb 2010 05:53:28 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1995#comment-1022</guid>
		<description><![CDATA[It&#039;s doesn&#039;t return the same results for &#039;lloyd&#039; and &#039;Lukasiewicz&#039; but it&#039;s close enough
[code]/* soundex.c - by harry moreno
 */
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

void removechars(char string[]);
void encode(char string[]);
void trim(char string[]);

main(void){  
  char buffer[100];
  int i;

  printf(&quot;Enter name:\n&quot;);
  scanf(&quot;%s&quot;, buffer);
  // make string lowercase
  for(i=0; buffer[i] != &#039;&#092;&#048;&#039;; i++){
    buffer[i] = tolower(buffer[i]);
  }

  removechars(buffer);
  printf(&quot;trimmed name:%s\n&quot;, buffer);
  encode(buffer);
  printf(&quot;encoded name:%s\n&quot;, buffer);
  trim(buffer);
  printf(&quot;Code produced: %s\n&quot;, buffer);
}

void removechars(char string[]){
  int i,j;
  
  for(i=1; string[i] != &#039;&#092;&#048;&#039;; i++){
    if(string[i] == string[i+1] &#124;&#124; string[i] == &#039;a&#039; &#124;&#124; string[i] == &#039;e&#039; &#124;&#124;
               string[i] == &#039;h&#039; &#124;&#124; string[i] == &#039;i&#039; &#124;&#124; string[i] == &#039;o&#039; &#124;&#124;
               string[i] == &#039;u&#039; &#124;&#124; string[i] == &#039;w&#039; &#124;&#124; string[i] == &#039;y&#039;){
      for(j=i; string[j] != &#039;&#092;&#048;&#039;; j++)
        string[j] = string[j+1];
      i--;
    }
  }
}

void trim(char string[]){
  int i,j;
  // remove dupes
  for(i=1; string[i] != &#039;&#092;&#048;&#039;; i++){
    if(string[i] == string[i+1]){
      for(j=i; string[j] != &#039;&#092;&#048;&#039;; j++)
        string[j] = string[j+1];
      i--;
    }
  }
  if(strlen(string)&gt;4)
    string[4] = &#039;&#092;&#048;&#039;;
  else {
    for(i=1; i&lt;4; i++){
      if(string[i] == &#039;&#092;&#048;&#039;){
        for(j=i; j&lt;4; j++)
          string[j] = &#039;0&#039;;
      }
    }
    string[4] = &#039;&#092;&#048;&#039;;
  }
}

void encode(char string[]){
  int i;
  
  for(i=1; string[i] != &#039;&#092;&#048;&#039;; i++){
    if(string[i] == &#039;b&#039; &#124;&#124; string[i] == &#039;f&#039; &#124;&#124; string[i] == &#039;p&#039; &#124;&#124;
       string[i] == &#039;v&#039;)
      string[i] = &#039;1&#039;;
    if(string[i] == &#039;c&#039; &#124;&#124; string[i] == &#039;g&#039; &#124;&#124; string[i] == &#039;j&#039; &#124;&#124;
       string[i] == &#039;k&#039; &#124;&#124; string[i] == &#039;q&#039; &#124;&#124; string[i] == &#039;s&#039; &#124;&#124;
       string[i] == &#039;x&#039; &#124;&#124; string[i] == &#039;z&#039;)
      string[i] = &#039;2&#039;;
    if(string[i] == &#039;d&#039; &#124;&#124; string[i] == &#039;t&#039;)
      string[i] = &#039;3&#039;;
    if(string[i] == &#039;l&#039;)
      string[i] = &#039;4&#039;;
    if(string[i] == &#039;m&#039; &#124;&#124; string[i] == &#039;n&#039;)
      string[i] = &#039;5&#039;;
    if(string[i] == &#039;r&#039;)
      string[i] = &#039;6&#039;;
  }
}[/code]]]></description>
		<content:encoded><![CDATA[<p>It&#8217;s doesn&#8217;t return the same results for &#8216;lloyd&#8217; and &#8216;Lukasiewicz&#8217; but it&#8217;s close enough</p>
<pre class="brush: plain;">/* soundex.c - by harry moreno
 */
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

void removechars(char string[]);
void encode(char string[]);
void trim(char string[]);

main(void){  
  char buffer[100];
  int i;

  printf(&quot;Enter name:\n&quot;);
  scanf(&quot;%s&quot;, buffer);
  // make string lowercase
  for(i=0; buffer[i] != '&#92;&#48;'; i++){
    buffer[i] = tolower(buffer[i]);
  }

  removechars(buffer);
  printf(&quot;trimmed name:%s\n&quot;, buffer);
  encode(buffer);
  printf(&quot;encoded name:%s\n&quot;, buffer);
  trim(buffer);
  printf(&quot;Code produced: %s\n&quot;, buffer);
}

void removechars(char string[]){
  int i,j;
  
  for(i=1; string[i] != '&#92;&#48;'; i++){
    if(string[i] == string[i+1] || string[i] == 'a' || string[i] == 'e' ||
               string[i] == 'h' || string[i] == 'i' || string[i] == 'o' ||
               string[i] == 'u' || string[i] == 'w' || string[i] == 'y'){
      for(j=i; string[j] != '&#92;&#48;'; j++)
        string[j] = string[j+1];
      i--;
    }
  }
}

void trim(char string[]){
  int i,j;
  // remove dupes
  for(i=1; string[i] != '&#92;&#48;'; i++){
    if(string[i] == string[i+1]){
      for(j=i; string[j] != '&#92;&#48;'; j++)
        string[j] = string[j+1];
      i--;
    }
  }
  if(strlen(string)&gt;4)
    string[4] = '&#92;&#48;';
  else {
    for(i=1; i&lt;4; i++){
      if(string[i] == '&#92;&#48;'){
        for(j=i; j&lt;4; j++)
          string[j] = '0';
      }
    }
    string[4] = '&#92;&#48;';
  }
}

void encode(char string[]){
  int i;
  
  for(i=1; string[i] != '&#92;&#48;'; i++){
    if(string[i] == 'b' || string[i] == 'f' || string[i] == 'p' ||
       string[i] == 'v')
      string[i] = '1';
    if(string[i] == 'c' || string[i] == 'g' || string[i] == 'j' ||
       string[i] == 'k' || string[i] == 'q' || string[i] == 's' ||
       string[i] == 'x' || string[i] == 'z')
      string[i] = '2';
    if(string[i] == 'd' || string[i] == 't')
      string[i] = '3';
    if(string[i] == 'l')
      string[i] = '4';
    if(string[i] == 'm' || string[i] == 'n')
      string[i] = '5';
    if(string[i] == 'r')
      string[i] = '6';
  }
}</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Remco Niemeijer</title>
		<link>http://programmingpraxis.com/2010/02/16/soundex/#comment-1016</link>
		<dc:creator><![CDATA[Remco Niemeijer]]></dc:creator>
		<pubDate>Tue, 16 Feb 2010 10:30:07 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1995#comment-1016</guid>
		<description><![CDATA[Hm. I think I may have accidentally used src instead of css for the language in the post above. Here&#039;s the correct version.

[sourcecode lang=&quot;css&quot;]
import Data.Char
import Data.List

soundex :: String -&gt; String
soundex = f . map head . group . map toUpper where
    f []     = []
    f (x:xs) = x : take 3 [toNum c &#124; c &lt;- xs ++ repeat &#039;0&#039;, 
                                     notElem c &quot;AEHIOUWY&quot;]
    toNum c = maybe &#039;0&#039; snd . find (elem c . fst) $
              zip (words &quot;BFPV CGJKQSXZ DT L MN R&quot;) [&#039;1&#039;..]
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>Hm. I think I may have accidentally used src instead of css for the language in the post above. Here&#8217;s the correct version.</p>
<pre class="brush: css;">
import Data.Char
import Data.List

soundex :: String -&gt; String
soundex = f . map head . group . map toUpper where
    f []     = []
    f (x:xs) = x : take 3 [toNum c | c &lt;- xs ++ repeat '0', 
                                     notElem c &quot;AEHIOUWY&quot;]
    toNum c = maybe '0' snd . find (elem c . fst) $
              zip (words &quot;BFPV CGJKQSXZ DT L MN R&quot;) ['1'..]
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Remco Niemeijer</title>
		<link>http://programmingpraxis.com/2010/02/16/soundex/#comment-1015</link>
		<dc:creator><![CDATA[Remco Niemeijer]]></dc:creator>
		<pubDate>Tue, 16 Feb 2010 10:26:47 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1995#comment-1015</guid>
		<description><![CDATA[My Haskell solution (see http://bonsaicode.wordpress.com/2010/02/16/programming-praxis-soundex/ for a version with comments):

[sourcecode lang=&quot;src&quot;]
import Data.Char
import Data.List

soundex :: String -&gt; String
soundex = f . map head . group . map toUpper where
    f []     = []
    f (x:xs) = x : take 3 [toNum c &#124; c &lt;- xs ++ repeat &#039;0&#039;, 
                                     notElem c &quot;AEHIOUWY&quot;]
    toNum c = maybe &#039;0&#039; snd . find (elem c . fst) $
              zip (words &quot;BFPV CGJKQSXZ DT L MN R&quot;) [&#039;1&#039;..]
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>My Haskell solution (see <a href="http://bonsaicode.wordpress.com/2010/02/16/programming-praxis-soundex/" rel="nofollow">http://bonsaicode.wordpress.com/2010/02/16/programming-praxis-soundex/</a> for a version with comments):</p>
<p>import Data.Char<br />
import Data.List</p>
<p>soundex :: String -&gt; String<br />
soundex = f . map head . group . map toUpper where<br />
    f []     = []<br />
    f (x:xs) = x : take 3 [toNum c | c &lt;- xs ++ repeat '0',<br />
                                     notElem c &quot;AEHIOUWY&quot;]<br />
    toNum c = maybe '0' snd . find (elem c . fst) $<br />
              zip (words &quot;BFPV CGJKQSXZ DT L MN R&quot;) ['1'..]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

