Re: Another conversion to C or Java...
- From: Pascal Bourguignon <spam@xxxxxxxxxxxxxxxx>
- Date: Tue, 29 Nov 2005 18:23:51 +0100
"Marco Minerva" <marco.minerva@xxxxxxxxxx> 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
.
- Follow-Ups:
- Re: Another conversion to C or Java...
- From: Marco Minerva
- Re: Another conversion to C or Java...
- From: mmcconnell17704
- Re: Another conversion to C or Java...
- References:
- Another conversion to C or Java...
- From: Marco Minerva
- Another conversion to C or Java...
- Prev by Date: Re: Reddit Guys on the Pros and Cons of Lisp
- Next by Date: Re: Hints on recursion
- Previous by thread: Another conversion to C or Java...
- Next by thread: Re: Another conversion to C or Java...
- Index(es):
Relevant Pages
|