Commit b6d8d34a authored by Philipp Stephani's avatar Philipp Stephani

* doc/lispref/internals.texi (Module Values): Add a GMP example

parent c4bacb12
Pipeline #1437 failed with stage
in 6 minutes
......@@ -1543,6 +1543,31 @@ integral object. After you have finished using
or similar.
@end deftypefn
The following example uses GMP to calculate the next probable prime
after a given integer:
#include <assert.h>
#include <gmp.h>
#include <emacs-module.h>
static emacs_value
next_prime (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
void *data)
assert (nargs == 1);
emacs_mpz p;
mpz_init (p.value);
env->extract_big_integer (env, args[0], &p);
mpz_nextprime (p.value, p.value);
emacs_value result = env->make_big_integer (env, &p);
mpz_clear (p.value);
return result;
@end example
The @acronym{API} does not provide functions to manipulate Lisp data
structures, for example, create lists with @code{cons} and @code{list}
(@pxref{Building Lists}), extract list members with @code{car} and
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment