From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/87527 Path: news.gmane.org!not-for-mail From: Matthias Weber Newsgroups: gmane.comp.tex.context Subject: Re: Simple command with variable number of arguments Date: Fri, 23 May 2014 08:12:13 -0400 Message-ID: <2D87CD62-883B-430A-87D4-EDA784BDAF1D@indiana.edu> References: <6EAF5FDE-7BE4-4766-B683-FA9994227A04@indiana.edu> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Content-Type: multipart/mixed; boundary="===============1496598318==" X-Trace: ger.gmane.org 1400847165 16807 80.91.229.3 (23 May 2014 12:12:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 23 May 2014 12:12:45 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri May 23 14:12:40 2014 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([5.39.185.229]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WnoL1-0003Gs-DE for gctc-ntg-context-518@m.gmane.org; Fri, 23 May 2014 14:12:39 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 31A5C1022B for ; Fri, 23 May 2014 14:12:39 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id WZKKdYqLoOvn for ; Fri, 23 May 2014 14:12:39 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id B15C01022C for ; Fri, 23 May 2014 14:12:34 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 5723A101EC for ; Fri, 23 May 2014 14:12:30 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id pzJeUEtBg4SL for ; Fri, 23 May 2014 14:12:28 +0200 (CEST) Original-Received: from filter5-til.mf.surf.net (filter5-til.mf.surf.net [194.171.167.221]) by balder.ntg.nl (Postfix) with ESMTP id 9D63C101E8 for ; Fri, 23 May 2014 14:12:20 +0200 (CEST) Original-Received: from hartman.uits.indiana.edu (belushi.uits.indiana.edu [129.79.1.188]) by filter5-til.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id s4NCCFZS024919 for ; Fri, 23 May 2014 14:12:18 +0200 X-IronPort-AV: E=Sophos;i="4.98,893,1392181200"; d="asc'?scan'208,217";a="141205237" Original-Received: from mssg-relay.indiana.edu ([129.79.1.73]) by irpt-internal-relay.indiana.edu with ESMTP; 23 May 2014 08:12:15 -0400 Original-Received: from hartman.uits.indiana.edu (hartman.uits.indiana.edu [129.79.1.194]) by mssg-relay.indiana.edu (8.14.7/8.14.4/IU Messaging Team) with ESMTP id s4NCCBI3024541 for ; Fri, 23 May 2014 08:12:15 -0400 X-IronPort-AV: E=Sophos;i="4.98,893,1392181200"; d="asc'?scan'208,217";a="141238596" Original-Received: from burns.uits.indiana.edu (HELO mail-relay.iu.edu) ([129.79.1.202]) by irpt-internal-relay.indiana.edu with ESMTP; 23 May 2014 08:12:14 -0400 Original-Received: from [172.27.35.85] (c-98-223-200-195.hsd1.in.comcast.net [98.223.200.195]) (authenticated bits=0) by mail-relay.iu.edu (8.14.7/8.14.4/IU Messaging Team) with ESMTP id s4NCCE6w008746 for ; Fri, 23 May 2014 08:12:14 -0400 In-Reply-To: X-Mailer: Apple Mail (2.1874) X-Bayes-Prob: 0.0001 (Score 0, tokens from: ntg-context@ntg.nl, base:default, @@RPTN) X-CanIt-Geo: ip=129.79.1.188; country=US; region=Indiana; city=Bloomington; latitude=39.1653; longitude=-86.5264; http://maps.google.com/maps?q=39.1653,-86.5264&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0WM5ocfc3 - d96f831338f9 - 20140523 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.221 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:87527 Archived-At: --===============1496598318== Content-Type: multipart/signed; boundary="Apple-Mail=_37F6AE2C-B0BD-4DF2-B6FA-E0908DB5D5E0"; protocol="application/pgp-signature"; micalg=pgp-sha512 --Apple-Mail=_37F6AE2C-B0BD-4DF2-B6FA-E0908DB5D5E0 Content-Type: multipart/alternative; boundary="Apple-Mail=_78549B84-A401-412A-8568-1DD885BE258A" --Apple-Mail=_78549B84-A401-412A-8568-1DD885BE258A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 Thanks Luigi! Now I have a lot to play with=85 Matthias On May 23, 2014, at 7:44 AM, luigi scarso = wrote: >=20 >=20 >=20 > On Fri, May 23, 2014 at 11:54 AM, Matthias Weber = wrote: > Dear All, >=20 > I would like to define a command that expands >=20 > \vector{2,4} % or vector[2,4] if that=92s easier >=20 > to >=20 > \startpmatrix > \NC 2 \NR > \NC 4 \NR > \stoppmatrix >=20 > and more generally >=20 > \vector{2,4,1,7} >=20 > to >=20 > \startpmatrix > \NC 2 \NR > \NC 4 \NR > \NC 1 \NR > \NC 7 \NR > \stoppmatrix >=20 > Any hints how to achieve this? >=20 > Thanks, >=20 >=20 >=20 > \definemathmatrix > [pmatrix] > [left=3D{\left(\,},right=3D{\,\right)}] >=20 > \startluacode > document =3D document or {} > document.matthias =3D document.matthias or {}=20 > local function lua_columnvector(a) > context.startpmatrix() > for i,v in ipairs(a) do > context.NC() context(tostring(v)) context.NR() > end > context.stoppmatrix() > end > document.matthias.lua_columnvector =3D = document.matthias.lua_columnvector or lua_columnvector > \stopluacode >=20 > \def\columnvector#1{\ctxlua{document.matthias.lua_columnvector(#1)}} >=20 > \starttext > \startformula > \columnvector{{1,2,3}} %% watch the double { ! > \stopformula >=20 >=20 > \stoptext >=20 > --=20 > luigi > = __________________________________________________________________________= _________ > If your question is of interest to others as well, please add an entry = to the Wiki! >=20 > 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 > = __________________________________________________________________________= _________ --Apple-Mail=_78549B84-A401-412A-8568-1DD885BE258A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252 Thanks = Luigi! Now I have a lot to play = with=85

Matthias


O= n May 23, 2014, at 7:44 AM, luigi scarso <luigi.scarso@gmail.com> = wrote:




On Fri, May 23, 2014 at 11:54 AM, Matthias Weber = <matweber@indiana.edu> wrote:
Dear All,

I would like to define a command that expands

\vector{2,4} % or vector[2,4] if that=92s easier

to

\startpmatrix
 \NC 2 \NR
 \NC 4 \NR
\stoppmatrix

and more generally

\vector{2,4,1,7}

to

\startpmatrix
 \NC 2 \NR
 \NC 4 \NR
\NC 1 \NR
\NC 7 \NR
\stoppmatrix

Any hints how to achieve this?

Thanks,



\definemathmatrix
  = [pmatrix]
  = [left=3D{\left(\,},right=3D{\,\right)}]

\startluacode
document =3D document or = {}
document.matthias =3D  document.matthias or = {} 
local function = lua_columnvector(a)
 context.startpmatrix()
 = ; for i,v in ipairs(a) do
     context.NC() context(tostring(v)) =  context.NR()
 end
 context.stoppmatrix= ()
end
document.matthias.lua_columnvector =3D = document.matthias.lua_columnvector  or lua_columnvector
=
\stopluacode

\def\columnvector#1{\ctxlua{doc= ument.matthias.lua_columnvector(#1)}}

\starttext<= /div>
\startformula
\columnvector{{1,2,3}} %% watch the = double { !
=
\stopformula


\stoptext
<= /div>

--
luigi
= __________________________________________________________________________= _________
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.sup= elec.fr/projects/contextrev/
wiki     : http://contextgarden.net
________= __________________________________________________________________________= _

= --Apple-Mail=_78549B84-A401-412A-8568-1DD885BE258A-- --Apple-Mail=_37F6AE2C-B0BD-4DF2-B6FA-E0908DB5D5E0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJTfzsdAAoJELjBb0GFETax8NgP/1vTHwuAgXLiaIiaejZYJXr+ UDcK8pMECOE3EW8gAcuuOGBSO8MOWP/tcsyD0uesV3haCH1rzevbXDsSOng+5adi TXrgD+ffjnzEVsK+lYn3epK56314MQV/iKC/VtdiyZf5/6KA92REpeTVrpUKyfAa d+xuc3I4m/VP/9SjLGOhlaRA1VKKxiwrDKnpOrZUeMxXJDRu95ey+Cpqm7HsJGrP JT4yLBv9n4/8mVkrUSlJoW5XXsbvPZ5UfpvVjPBCLP7U3n9HdpERcdW9DYs/tctP PY0W3QpuqoyAnEU2WaC0JZRL77P/elH+s001XVRLauf8wrJAugHLcVHFKJstTegV UylPGSkEkpFdSkSFsBexzn+DsJmZsFv82Vj8FX6mFQ0kuSoFOmL81719V5W8yiTr NxMKuGLSbDauGR5KevrAP0MO3pbRBKuXqhb5Y9cXhooP18vxTrWfo/95caLAuRtL N7WJoPwEe6eehJU8ATJE5xKqzKgDw9YbIaA2tGSX0hzKMm99M+d9+AZiueTS7mRe BbHnuKKwvzxZmQA6QYw1Qba0LLRzYL62nxtCKS9rCTTs5PtZwZ/hiOlE2iJ2F7QM 7xBxiCyYpl9oAtM1NC8XWbVIGEgt0pENv27zJotjx+bWmSONIXN8lFnVp1xaRnXt uKVljfe8IE5+eF52KLnQ =J1oo -----END PGP SIGNATURE----- --Apple-Mail=_37F6AE2C-B0BD-4DF2-B6FA-E0908DB5D5E0-- --===============1496598318== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --===============1496598318==--