Re: [NTG-context] Code lua in a table

2020-07-18 Thread Otared Kavian


> On 18 Jul 2020, at 23:35, Otared Kavian  wrote:
> 
> 
> 
>> On 18 Jul 2020, at 22:25, Fabrice Couvreur  
>> wrote:
>> 
>> Hi Wolfgang,
>> 
>> It works but why did you ask this question since I finally use context ?
>> Are you sure you want to use context(...) here?
>> How not to display the .0 ?

Or even better, you can return an integer in your Binom function:

return math.round((n*Binom(n-1,k-1))/k)

Best regards: Otared
___
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
___


Re: [NTG-context] Code lua in a table

2020-07-18 Thread Otared Kavian


> On 18 Jul 2020, at 22:25, Fabrice Couvreur  
> wrote:
> 
> Hi Wolfgang,
> 
> It works but why did you ask this question since I finally use context ?
> Are you sure you want to use context(...) here?
> How not to display the .0 ?

Besides what Wolfgang suggested, ou can also use 
context(math.round(Binom(i,j)))
to have integers instead of real numbers.

Best regards: Otared
___
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
___


Re: [NTG-context] Code lua in a table

2020-07-18 Thread Wolfgang Schuster

Fabrice Couvreur schrieb am 18.07.2020 um 22:25:

Hi Wolfgang,

It works but why did you ask this question since I finally use context ?

Are you sure you want to use context(...) here?


In your first version you used the context function in the loop to print 
the output of the Binom but the Binom function used context as well, 
this could result in context(context(...)).



How not to display the .0 ?


Format the content of the context function to show only integer values, 
e.g. context("%d",Binom(...)).


For more information search for formatter in cld-mkiv.pdf.

Wolfgang
___
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
___


Re: [NTG-context] Code lua in a table

2020-07-18 Thread Fabrice Couvreur
Small correction :

\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

end

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

\stopluacode

\stoptext

Le sam. 18 juil. 2020 à 22:25, Fabrice Couvreur 
a écrit :

> Hi Wolfgang,
>
> It works but why did you ask this question since I finally use context ?
>
>> Are you sure you want to use context(...) here?
>>
> How not to display the .0 ?
> Fabrice
>
> Le sam. 18 juil. 2020 à 22:22, Wolfgang Schuster <
> wolfgang.schuster.li...@gmail.com> a écrit :
>
>> Fabrice Couvreur schrieb am 18.07.2020 um 22:09:
>> > Hi,
>> > I improved the code to be able to display the grid but I cannot display
>> > the coefficients.
>> > 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
>> >
>> >  end
>> >
>> >  context.startxtable({"align={middle,lohi},
>> > width=1.2cm,offset=0.8ex,bodyfont=9pt"})
>> >  for i = 1, 10 do
>> >context.startxrow({"background=color,backgroundcolor=cyan"})
>> >  for j = 1, i do
>> >context.startxcell()
>> >   \ctxlua{context(Binom(i,j))}
>>
>> Remove \ctxlua:
>>
>> context(Binom(i,j))
>>
>> Wolfgang
>>
>> ___
>> 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
>>
>> ___
>>
>
___
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
___


Re: [NTG-context] Code lua in a table

2020-07-18 Thread Fabrice Couvreur
Hi Wolfgang,

It works but why did you ask this question since I finally use context ?

> Are you sure you want to use context(...) here?
>
How not to display the .0 ?
Fabrice

Le sam. 18 juil. 2020 à 22:22, Wolfgang Schuster <
wolfgang.schuster.li...@gmail.com> a écrit :

> Fabrice Couvreur schrieb am 18.07.2020 um 22:09:
> > Hi,
> > I improved the code to be able to display the grid but I cannot display
> > the coefficients.
> > 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
> >
> >  end
> >
> >  context.startxtable({"align={middle,lohi},
> > width=1.2cm,offset=0.8ex,bodyfont=9pt"})
> >  for i = 1, 10 do
> >context.startxrow({"background=color,backgroundcolor=cyan"})
> >  for j = 1, i do
> >context.startxcell()
> >   \ctxlua{context(Binom(i,j))}
>
> Remove \ctxlua:
>
> context(Binom(i,j))
>
> Wolfgang
>
> ___
> 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
>
> ___
>
___
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
___


Re: [NTG-context] Code lua in a table

2020-07-18 Thread Wolfgang Schuster

Fabrice Couvreur schrieb am 18.07.2020 um 22:09:

Hi,
I improved the code to be able to display the grid but I cannot display 
the coefficients.

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

     end

     context.startxtable({"align={middle,lohi}, 
width=1.2cm,offset=0.8ex,bodyfont=9pt"})

     for i = 1, 10 do
           context.startxrow({"background=color,backgroundcolor=cyan"})
             for j = 1, i do
                   context.startxcell()
                      \ctxlua{context(Binom(i,j))}


Remove \ctxlua:

context(Binom(i,j))

Wolfgang
___
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
___


Re: [NTG-context] Code lua in a table

2020-07-18 Thread Fabrice Couvreur
Hi,
I improved the code to be able to display the grid but I cannot display the
coefficients.
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

end

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

\stopluacode

\stoptext


Le sam. 18 juil. 2020 à 20:32, Wolfgang Schuster <
wolfgang.schuster.li...@gmail.com> a écrit :

> Fabrice Couvreur schrieb am 18.07.2020 um 20:05:
>
> 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))
>
> Are you sure you want to use context(...) here?
>
> 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()
>
> context.stopxtable()
>
> Wolfgang
>
>
> ___
> 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
>
> ___
>
___
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
___


Re: [NTG-context] french translation of ConTeXt interface - progress (v3)

2020-07-18 Thread Hans Hagen

On 7/18/2020 8:56 PM, Garulfo wrote:

 > @Garulfo: Do you have a special use case in mind, or do you do this
 > for fun?

"for fun" isn't quite right, although there's probably some truth to it.
Actually, translating 6,300 keywords isn't fun, and it's even worst when 
you don't really master the material behind...


but i guess you learn a lot in the process

The point is that I am sad to not be able to offer the use of ConTeXt 
(such a great piece of software) to friends and childrens.

And ConTeXt complexity or ConTeXt documentation are not the first hurdles.


indeed (which is why for instance we use the dutch for e.g. family members)

most users actually can do with a limited set of commands to start with 
... and writing a tutorial for that is doable ... it's still on my 
agenda to come up with something for kids and translated interfaces are 
needed for that (unless we ditch all languages for english .. but if 
that happens, we can actually do without tex because a large portion, at 
least in context, is dedicated to dealing with scripts and languages)


When you start with a new software, a new methodology, having first to 
struggle with vocabulary in a foreign language is definitively a (BIG) 
thorn in your side (in fact, usually you just don't start).


Many popular softwares offer multi-language early in their development 
(netscape / firefox, scratch, wordpress, krita...).
ConTeXt did it, the infrastructure is ready, the translations exist, at 
least partially or at an early stage.


indeed, it was there right from the start ... as a historic note: the 
reason what that we had a subsystem for chemistry which could be 
configured usinng key values (we're talking early nineties) and in order 
to be used in german we made the multi lingual interface (after that the 
english and others lists were added) .. the german was done with Tobias 
Burnus who also helped with the early multi language support)


context goes along way back ...

And when I started to use it, I thought that it could easily be improved 
and updated without requiring any Tex / Lua skills.


One remark : I was wrong, I spend hours to put all the content (from 
mult-def and context-en.xml) in a simple csv table and building 
quick scripts to put it back in mult-def.


(normally i then put up some music or a movies i already saw before in 
the background or some podcast or ...)



 > With our small developer and user base we struggle enough with keeping
 > documentation current.

Struggle likely appears about not-so-trivial needs.

It's a shame not to use it in Italian / Russian / Chinese / French 
etc... for a letter, for a 10 to 20 pages report, for an internal note.


exactly ... (btw, tex promotion is often tight to scientific publishing 
but the interesting fact there is that as soon as you drop the formulas 
it often doesn't look that pretty any more .. another property of 
context is that users should be able to make a nice layout)


All the more so as the software allows it. The point is that the 
interface just deserves a minimal update and documentation, and that, as 
you point it, the small developer and user base doesn't have time to do it.

indeed, and sorry for not keeping it up to date

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
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
___


Re: [NTG-context] french translation of ConTeXt interface - progress (v3)

2020-07-18 Thread Garulfo

> @Garulfo: Do you have a special use case in mind, or do you do this
> for fun?

"for fun" isn't quite right, although there's probably some truth to it.
Actually, translating 6,300 keywords isn't fun, and it's even worst when 
you don't really master the material behind...


The point is that I am sad to not be able to offer the use of ConTeXt 
(such a great piece of software) to friends and childrens.

And ConTeXt complexity or ConTeXt documentation are not the first hurdles.

When you start with a new software, a new methodology, having first to 
struggle with vocabulary in a foreign language is definitively a (BIG) 
thorn in your side (in fact, usually you just don't start).


Many popular softwares offer multi-language early in their development 
(netscape / firefox, scratch, wordpress, krita...).
ConTeXt did it, the infrastructure is ready, the translations exist, at 
least partially or at an early stage.


And when I started to use it, I thought that it could easily be improved 
and updated without requiring any Tex / Lua skills.


One remark : I was wrong, I spend hours to put all the content (from 
mult-def and context-en.xml) in a simple csv table and building 
quick scripts to put it back in mult-def.




> With our small developer and user base we struggle enough with keeping
> documentation current.

Struggle likely appears about not-so-trivial needs.

It's a shame not to use it in Italian / Russian / Chinese / French 
etc... for a letter, for a 10 to 20 pages report, for an internal note.


All the more so as the software allows it. The point is that the 
interface just deserves a minimal update and documentation, and that, as 
you point it, the small developer and user base doesn't have time to do it.





___
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
___


Re: [NTG-context] Code lua in a table

2020-07-18 Thread Wolfgang Schuster

Fabrice Couvreur schrieb am 18.07.2020 um 20:05:

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

Are you sure you want to use context(...) here?

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

context.stopxtable()

Wolfgang

___
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
___


[NTG-context] Code lua in a table

2020-07-18 Thread Fabrice Couvreur
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
___
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
___