From: Coldfire
Subject: translation for a few lines of lisp code please.
Date: 
Message-ID: <1175634201.875818.32560@n59g2000hsh.googlegroups.com>
Hi!,

I am trying to understand paul grahams spam algorithm. He has given a
small lisp snippet in the discussion. I plan to learn lisp, but I want
to understand this one for my school project right now. can anyone
give a c translation of these lines.

(let ((g (* 2 (or (gethash word good) 0)))
          (b (or (gethash word bad) 0)))
       (unless (< (+ g b) 5)
           (max .01
               (min .99 (float (/ (min 1 (/ b nbad))
                     (+ (min 1 (/ g ngood))
                         (min 1 (/ b nbad)))))))))

Your help is much appreciated.
Thanks,
Coldfire.

From: Kaz Kylheku
Subject: Re: translation for a few lines of lisp code please.
Date: 
Message-ID: <1175634612.217550.309110@n76g2000hsh.googlegroups.com>
On Apr 3, 2:03 pm, "Coldfire" <············@gmail.com> wrote:
> Hi!,
>
> I am trying to understand paul grahams spam algorithm. He has given a
> small lisp snippet in the discussion. I plan to learn lisp, but I want
> to understand this one for my school project right now. can anyone
> give a c translation of these lines.

This was the topic of a thread in late 2005.

Google Groups URL:

  http://groups.google.ca/group/comp.lang.lisp/browse_frm/thread/6a1c7b4671ee083d/096061a55b40410c

Message ID of root article:

  <·························@reader3.news.tin.it>
From: Coldfire
Subject: Re: translation for a few lines of lisp code please.
Date: 
Message-ID: <1175636646.459723.61610@w1g2000hsg.googlegroups.com>
Thanks Kaz, I should have guessed this would have come up!

On Apr 3, 5:10 pm, "Kaz Kylheku" <········@gmail.com> wrote:
> On Apr 3, 2:03 pm, "Coldfire" <············@gmail.com> wrote:
>
> > Hi!,
>
> > I am trying to understand paul grahams spam algorithm. He has given a
> > small lisp snippet in the discussion. I plan to learn lisp, but I want
> > to understand this one for my school project right now. can anyone
> > give a c translation of these lines.
>
> This was the topic of a thread in late 2005.
>
> Google Groups URL:
>
>  http://groups.google.ca/group/comp.lang.lisp/browse_frm/thread/6a1c7b...
>
> Message ID of root article:
>
>   <·························@reader3.news.tin.it>
From: Kjetil Svalastog Matheussen
Subject: Re: translation for a few lines of lisp code please.
Date: 
Message-ID: <Pine.LNX.4.58.0704032325590.31588@notam02.uio.no>
On Tue, 3 Apr 2007, Coldfire wrote:

> Hi!,
> 
> I am trying to understand paul grahams spam algorithm. He has given a
> small lisp snippet in the discussion. I plan to learn lisp, but I want
> to understand this one for my school project right now. can anyone
> give a c translation of these lines.
> 
> (let ((g (* 2 (or (gethash word good) 0)))
>           (b (or (gethash word bad) 0)))
>        (unless (< (+ g b) 5)
>            (max .01
>                (min .99 (float (/ (min 1 (/ b nbad))
>                      (+ (min 1 (/ g ngood))
>                          (min 1 (/ b nbad)))))))))
> 

Something like this:

int gh=gethash(word,good)
int g=2*gh==FALSE?0:gh

int bh=gethash(word,bad);
int b=bh==FALE?0:bh;

if( ! ((g+b)<5))
  return(MAX(0.01,MIN(0.99, (float) (MIN(1,(b/nbad))
                                     / ( MIN(1,g/ngood) +
                                         MIN(1,b/nbad))))));