From: Marco Minerva
Subject: Another conversion to C or Java...
Date: 
Message-ID: <1133284300.940721.309550@g47g2000cwa.googlegroups.com>
Hi all!

Excuse me, but I need another help translating a small piece of Lisp
code to C or Java:

(let ((prod (apply #'* probs)))
  (/ prod (+ prod (apply #'* (mapcar #'(lambda (x)
                                         (- 1 x))
                                     probs)))))

Where "probs" is a list of the fifteen individual probabilities, i.e. a
list of 15 numbers between 0 and 1.

It's again from Paul Graham's spam algorithm...

Thanks in advance,
Marco Minerva, ·············@tiscali.it

From: Marco Antoniotti
Subject: Re: Another conversion to C or Java...
Date: 
Message-ID: <Dl1jf.94$pa3.30449@typhoon.nyu.edu>
Why do you insist on hurting yourself?  Have you not heard of the famous 
quote about Nutella?  :)

Cheers
--
Marco


Marco Minerva wrote:
> Hi all!
> 
> Excuse me, but I need another help translating a small piece of Lisp
> code to C or Java:
> 
> (let ((prod (apply #'* probs)))
>   (/ prod (+ prod (apply #'* (mapcar #'(lambda (x)
>                                          (- 1 x))
>                                      probs)))))
> 
> Where "probs" is a list of the fifteen individual probabilities, i.e. a
> list of 15 numbers between 0 and 1.
> 
> It's again from Paul Graham's spam algorithm...
> 
> Thanks in advance,
> Marco Minerva, ·············@tiscali.it
> 
From: Ulrich Hobelmann
Subject: Re: Another conversion to C or Java...
Date: 
Message-ID: <3v3oijF13r8ncU1@individual.net>
Marco Antoniotti wrote:
> Why do you insist on hurting yourself?  Have you not heard of the famous 
> quote about Nutella?  :)

He who likes Nutella
eats faster, plus vite, schneller?

SCNR

-- 
The road to hell is paved with good intentions.
From: Marco Antoniotti
Subject: Re: Another conversion to C or Java...
Date: 
Message-ID: <Xo2jf.95$pa3.30699@typhoon.nyu.edu>
No sorry :)  It is a very italian inside joke :)


Cheers
--
Marco





Ulrich Hobelmann wrote:
> Marco Antoniotti wrote:
> 
>> Why do you insist on hurting yourself?  Have you not heard of the 
>> famous quote about Nutella?  :)
> 
> 
> He who likes Nutella
> eats faster, plus vite, schneller?
> 
> SCNR
> 
From: Pascal Bourguignon
Subject: Re: Another conversion to C or Java...
Date: 
Message-ID: <871x0znza0.fsf@thalassa.informatimago.com>
"Marco Minerva" <·············@tiscali.it> writes:

> Hi all!
>
> Excuse me, but I need another help translating a small piece of Lisp
> code to C or Java:
>
> (let ((prod (apply #'* probs)))
>   (/ prod (+ prod (apply #'* (mapcar #'(lambda (x)
>                                          (- 1 x))
>                                      probs)))))
>
> Where "probs" is a list of the fifteen individual probabilities, i.e. a
> list of 15 numbers between 0 and 1.
>
> It's again from Paul Graham's spam algorithm...

#include <greenspun.h>
float one_minus_x(float x){return(1-x);}
float truc(cons_t* probs){
    cons_t* prod=apply(mul,probs);
    return(prod/(prod+apply(mul,mapcar(one_minus_x,probs))));}


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Until real software engineering is developed, the next best practice
is to develop with a dynamic system that has extreme late binding in
all aspects. The first system to really do this in an important way
is Lisp. -- Alan Kay
From: ···············@yahoo.com
Subject: Re: Another conversion to C or Java...
Date: 
Message-ID: <1133287788.113379.96410@f14g2000cwb.googlegroups.com>
x = p1*p2*...*p15;
y = (1-p1)*(1-p2)*...*(1-p15);
return x/(x+y);
From: Marco Minerva
Subject: Re: Another conversion to C or Java...
Date: 
Message-ID: <1133340611.418768.65830@g49g2000cwa.googlegroups.com>
Thanks a lot!

Where could I find the "greenspun.h" header?

Marco Minerva, ·············@tiscali.it
From: André Thieme
Subject: Re: Another conversion to C or Java...
Date: 
Message-ID: <1133341266.093726.122620@f14g2000cwb.googlegroups.com>
You don't need to copy Lisp-style in C (or Java).
If you program in C as one should do it you could maybe do something
like:

double temp1[15], prod = 1, temp = 1;
for (i=0; i<15; i++) {
  prod *= probs[i];
  temp *= 1-probs[i];
}
return prod/(temp+prod);
From: Marco Antoniotti
Subject: Re: Another conversion to C or Java...
Date: 
Message-ID: <F2jjf.96$pa3.31576@typhoon.nyu.edu>
Google "Greenspun Tenth Rule" :)

Cheers
--
Marco


Marco Minerva wrote:
> Thanks a lot!
> 
> Where could I find the "greenspun.h" header?
> 
> Marco Minerva, ·············@tiscali.it
> 
From: Kaz Kylheku
Subject: Re: Another conversion to C or Java...
Date: 
Message-ID: <1133378894.562279.157720@o13g2000cwo.googlegroups.com>
Marco Minerva wrote:
> Thanks a lot!
>
> Where could I find the "greenspun.h" header?

In every sufficiently complex software project written in C or C++. The
actual name of the header may vary, or it may be more than one header.
From: jayessay
Subject: Re: Another conversion to C or Java...
Date: 
Message-ID: <m3hd9ukq12.fsf@rigel.goldenthreadtech.com>
"Marco Minerva" <·············@tiscali.it> writes:

> Thanks a lot!
> 
> Where could I find the "greenspun.h" header?

LOL!!


/Jon

-- 
'j' - a n t h o n y at romeo/charley/november com