View Single Post
  #9  
Old 10-29-2009, 10:57 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
That's a hell of a lot of temp's though! And is there really a lot of confusion? I mean in this day and age usually if you see a var without a prefix you can undoubtedly know that it is a temp var. And it looks so much neater!

PHP Code:
function levenshtein(s, t) {
  
temp.m = s.length();
  
temp.n = t.length();
  
  
temp.d = new[m][n];
  for (
temp.i = 0; i <= m; i++) d[i][0] = i;
  for (
temp.j = 0; j <= n; j++) d[0][j] = j;
  
  for (
temp.j = 1; j <= n; j++) {
    for (
temp.i = 1; i <= m; i++) {
      if (
s.charat(i-1) == t.charat(j-1)) { 
        
d[i][j] = d[i-1][j-1];
      } else {
        
d[i][j] = min(d[i-1][j] + 1,
                      
min(d[i][j-1] + 1, d[i-1][j-1] + 1)
                     );
      }
    }
  }
  return 
d[m-1][n-1];
} 
Reply With Quote