Bonjour,
I am new in ConTeXt. I love its features. I need some (or a lot of) help.
I tried to get a macro which compute some values for a math function. With help
from the wiki ConTeXt Garden and some time I could do that 
- write my function userdata.f
- write another function to put the values in a table : userdata.tabf
- put both of them in a file "/Users/rolandt/context/mesfonctionsluatex.lua"
- In a file.tex, I use that macro : 
\def\tabf#1#2%
{\startluacode
dofile("/Users/rolandt/context/mesfonctionsluatex.lua")
userdata.tabf(#1,#2)
\stopluacode}


Here are the functions:

-- fonction cube
-- on utilise l'espace de nom userdata
userdata=userdata or {}

function userdata.f(x)
   context(x*x*x)
end

-- fonction tabf
-- which makes a table , compute  6 values, b=first x, c = step

userdata=userdata or {}

function userdata.tabf(b,c)
     context.starttable{"*{7}{|l}|"}
local b=b
local c=c
context("\\HL")
context("\\VL x ")      for i=1,6 do context("\\NC" .. b+(i-1)*c) end
context("\\VL".."\\AR")
context("\\HL")
context("\\VL f(x) ") for i=1,6 do context("\\NC")
context(userdata.f(b+(i-1)*c)) end 
context("\\VL".."\\LR")
context("\\HL")
context.stoptable()
end

I am sure it could be much better but it works !
Evidently I need a third argument to be able to choose how many values compute.
I failed completely (I don't understand how arguments are passed).
I tried things like : context.starttable{"*{%s}{|l}|",a} but ... fatal error :)
I would appreciate some help or  what to read to improve understanding that kind
of things.
Best regards,
Roland



___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to