Re: Another conversion to C or Java...



"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
.



Relevant Pages

  • Re: Multi-User Lisp Environments
    ... > environment vs. Java. ... > a running environment and have restarts, ... or you'll have to look the source instead of the lisp image. ... is to develop with a dynamic system that has extreme late binding in ...
    (comp.lang.lisp)
  • Another conversion to C or Java...
    ... but I need another help translating a small piece of Lisp ... code to C or Java: ... Where "probs" is a list of the fifteen individual probabilities, ...
    (comp.lang.lisp)
  • Re: Learning Lisp the hard way
    ... Note I do not want to advocate Java over lisp, ... Unless you can use Windows to program AllegroCL (or also some *nixes, I forget which, where they have ported their IDE) because they do have a nice IDE closer to what you are used to in Java. ... Next on my list of disappointments is exception handling. ...
    (comp.lang.lisp)
  • Re: Learning Lisp the hard way
    ... Note I do not want to advocate Java over lisp, ... they have ported their IDE) because they do have a nice IDE closer to ... Next on my list of disappointments is exception handling. ...
    (comp.lang.lisp)
  • Re: Is anything easier to do in java than in lisp?
    ... And any experienced lisp ... in java generally you hardly ever use ... static String showInputDialog(Component parentComponent, ... which was about generic sequences (lists ...
    (comp.lang.java)