ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Code lua in a table
@ 2020-07-18 18:05 Fabrice Couvreur
  2020-07-18 18:32 ` Wolfgang Schuster
  0 siblings, 1 reply; 15+ messages in thread
From: Fabrice Couvreur @ 2020-07-18 18:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 773 bytes --]

Hello,
I want to display the values of Pascal's triangle in a table.
Unfortunately my knowledge of Lua is not sufficient to run this code.
Thank you.
Fabrice

\starttext

\startluacode
     function Binom(n,k)
       if k > n then
             return 0
       elseif (n == 0 or k == 0) then
             return 1
       else
             return (n*Binom(n-1,k-1))/k
     end
             context(Binom(n,k))
    end

    context.startxtable({"align={middle,lohi},
width=1.2cm,offset=0.8ex,bodyfont=9pt"})
    context.startxrow({"background=color,backgroundcolor=green"})
    for i = 0, 10 do
      for j = 0, i do
          context.startxcell()
            context(Binom(i,j))
          context.stopxcell()
      end
    end
    context.stopxrow()

\stopluacode

\stoptext

[-- Attachment #1.2: Type: text/html, Size: 1623 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 15+ messages in thread
[parent not found: <mailman.1.1595152801.23549.ntg-context@ntg.nl>]

end of thread, other threads:[~2020-07-21 13:08 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-18 18:05 Code lua in a table Fabrice Couvreur
2020-07-18 18:32 ` Wolfgang Schuster
2020-07-18 20:09   ` Fabrice Couvreur
2020-07-18 20:22     ` Wolfgang Schuster
2020-07-18 20:25       ` Fabrice Couvreur
2020-07-18 20:34         ` Fabrice Couvreur
2020-07-18 20:36         ` Wolfgang Schuster
2020-07-18 21:35         ` Otared Kavian
2020-07-18 22:05           ` Otared Kavian
     [not found] <mailman.1.1595152801.23549.ntg-context@ntg.nl>
2020-07-20  5:56 ` Jeong Dal
2020-07-20  8:36   ` Hans Hagen
2020-07-20 10:13     ` Fabrice Couvreur
2020-07-20 12:40     ` Jeong Dal
2020-07-20 12:54       ` Hans Hagen
2020-07-21 13:08         ` Fabrice Couvreur

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).