From: Fabrice Couvreur via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Fabrice Couvreur <fabrice1.couvreur@gmail.com>
Subject: Create the values of a sequence with Lua
Date: Mon, 31 Oct 2022 17:48:18 +0100 [thread overview]
Message-ID: <CACyK-eq87Xt-+Et4UXa8ragEjT2PVSwzC5jXRW5wYB8cKi--4A@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 645 bytes --]
Hi,
The idea is to fill the array with the sequence defined by
p(0) = 0.3 and p(n + 1) = 0.3 + 0.7*p(n)
The problem is that I don't really master Lua but I will learn when I have
some time!
Thanks for your help.
Fabrice
\starttext
\startluacode
context.startxtable({"align={middle,lohi},width=2cm,bodyfont=9pt"})
p = {}
p[0] = 0.3
for i=0,19 do
p[i+1] = 0.3+0.7*p[i]^2 end
context.startxrow()
for i=0,19 do
context.startxcell() context(i) context.stopxcell()
context.startxcell() context(i+1) context.stopxcell()
context.startxcell() context("%0.8f",p[i] ) context.stopxcell()
context.stopxrow()
end
context.stopxtable()
\stopluacode
\stoptext
[-- Attachment #1.2: Type: text/html, Size: 980 bytes --]
[-- Attachment #2: Type: text/plain, Size: 496 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
next reply other threads:[~2022-10-31 16:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-31 16:48 Fabrice Couvreur via ntg-context [this message]
2022-10-31 16:58 ` Aditya Mahajan via ntg-context
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACyK-eq87Xt-+Et4UXa8ragEjT2PVSwzC5jXRW5wYB8cKi--4A@mail.gmail.com \
--to=ntg-context@ntg.nl \
--cc=fabrice1.couvreur@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).