From: heinz
Subject: formatting a list of floats in elisp
Date: 
Message-ID: <110d1852.0207020117.2a080673@posting.google.com>
So far I managed to do some mapping of math 
functions to a list of floats giving a resulting
list: data.

Now I would like to produce an initialiser for 
an array of floats in C. The elisp for it all
should be contained as a comment in a C source
file.

The data will be something like (0.333 0.450 0.003)
and I want the result. (But the real length 128 
instead of 3):

<wanted>
static const float sp[3] = { 
               /* sp */ 
  /* SP_0 */ 	3.330e-01,
  /* SP_1 */ 	4.500e-01,
  /* SP_2 */ 	3.000e-03
}
</wanted>


I got this far:
(mapc (lambda(element)
		    (princ (format "\n%3.3e" element))
                    ) data)

Where data holds the floating point data.

What does it take to produce the text for 
the C array with initialiser in another
(named) buffer?

It seems like #'(lambda
               '(lambda
                (lambda
will do the same in the example above, what
is the difference? I learn by stealing and
in the example i stole it from it was #'(lambda


regards,
heinz
From: Kai =?iso-8859-15?q?Gro=DFjohann?=
Subject: Re: formatting a list of floats in elisp
Date: 
Message-ID: <vaf8z4unsfx.fsf@lucy.cs.uni-dortmund.de>
·····@flashmail.com (heinz) writes:

> What does it take to produce the text for 
> the C array with initialiser in another
> (named) buffer?

You could do

(save-excursion
  (set-buffer "other-buffer")
  (mapc ...))

kai
-- 
A large number of young women don't trust men with beards.  (BFBS Radio)