| Oct. 12th, 2005 04:02 pm C is BAD As part of a homework assignment a few years ago, I needed to be able to use Prolog to generate random numbers from a Gaussian (bell curve) distribution with a given mean and standard deviation. A friend found the code that does this in the Python standard library, so I translated it into Prolog.
When SWI Prolog 5.2.10 decompiles a compiled program, it names the first variable to occur A, the second B, and so on. Part of my translation of the Python looked like this in the source file: gaussian(SD,Mean,R) :-
gaussian_z(Z),
!,
retractall(gaussian_z(_)),
R is Mean + SD * Z. When compiled and displayed, it reads:gaussian(A, B, C) :-
gaussian_z(D), !,
retractall(gaussian_z(E)),
C is B+A*D. In spite of its apparent dislike of the language, I've since translated this from Prolog into C (really, C++) for a quick and dirty Gaussian random number generator for use in SAGA.2 comments - Leave a comment |
|