[cl-emb-devel] New release CL-EMB 0.3.0 (API CHANGES!)
Stefan Scholl
sscholl at common-lisp.net
Sun Feb 19 00:12:28 UTC 2006
On 2005-03-12 00:25:04, Stefan Scholl wrote:
> - Generator loops.
> The additional keyword parameter GENERATOR-MAKER to EXECUTE-EMB
> lets you supply a function, which returns a generator function.
> Generator functions are described on
> http://www.cs.northwestern.edu/academics/courses/325/readings/graham/generators.html
>
[...]
> A simple example from the README:
This example was broken. I fixed it in
http://common-lisp.net/project/cl-emb/README and the current
release 0.4.3.
CL-USER> (emb:register-emb "test10" "Square root from 1 to <% @var numbers %>: <% @genloop numbers %>sqrt(<% @var number %>) = <% @var sqrt %> <% @endgenloop %>")
#<CL-EMB::EMB-FUNCTION {581EC765}>
CL-USER> (defun make-sqrt-1-to-n-gen (key n)
(declare (ignore key))
(let ((i 1))
#'(lambda (cmd)
(ecase cmd
(:test (> i n))
(:get `(:number ,i :sqrt ,(sqrt i)))
(:next (prog1 `(:number ,i :sqrt ,(sqrt i))
(unless (> i n)
(incf i))))))))
MAKE-SQRT-1-TO-N-GEN
CL-USER> (emb:execute-emb "test10" :env '(:numbers 10) :generator-maker 'make-sqrt-1-to-n-gen)
"Square root from 1 to 10: sqrt(1) = 1.0 sqrt(2) = 1.4142135 sqrt(3) = 1.7320508 sqrt(4) = 2.0 sqrt(5) = 2.236068 sqrt(6) = 2.4494898 sqrt(7) = 2.6457512 sqrt(8) = 2.828427 sqrt(9) = 3.0 sqrt(10) = 3.1622777 "
More information about the cl-emb-devel
mailing list