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
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
>
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.
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
>
"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
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);
Google "Greenspun Tenth Rule" :)
Cheers
--
Marco
Marco Minerva wrote:
> Thanks a lot!
>
> Where could I find the "greenspun.h" header?
>
> Marco Minerva, ·············@tiscali.it
>
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.
"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