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.
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>
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>
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))))));