From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 23638 invoked from network); 25 Oct 2023 19:57:04 -0000 Received: from cgl.ntg.nl (5.39.185.202) by inbox.vuxu.org with ESMTPUTF8; 25 Oct 2023 19:57:04 -0000 Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 3A491483607 for ; Wed, 25 Oct 2023 21:54:38 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KqOAE0Au9dYF for ; Wed, 25 Oct 2023 21:54:37 +0200 (CEST) Received: from cgl.ntg.nl (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id C847A483747 for ; Wed, 25 Oct 2023 21:53:48 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 8E9B348305F for ; Wed, 25 Oct 2023 21:53:03 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j9xkf2zGEcsF for ; Wed, 25 Oct 2023 21:53:02 +0200 (CEST) Received: from orford.cim.mcgill.ca (orford.cim.mcgill.ca [132.206.70.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cgl.ntg.nl (Postfix) with ESMTPS id 87016482F4D for ; Wed, 25 Oct 2023 21:53:02 +0200 (CEST) Received: from carbonpad.cim.mcgill.ca (alille-655-1-37-200.w90-7.abo.wanadoo.fr [90.7.138.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: adityam) by orford.cim.mcgill.ca (Postfix) with ESMTPSA id 1CD6819F594 for ; Wed, 25 Oct 2023 15:53:15 -0400 (EDT) Date: Wed, 25 Oct 2023 21:52:58 +0200 (CEST) From: Aditya Mahajan X-X-Sender: adityam@carbonpad.cim.mcgill.ca To: mailing list for ConTeXt users In-Reply-To: <046d83a6-d4c5-4c01-99ed-57b83d555b86@Spark> Message-ID: <858p6424-2683-9873-944r-08ronp9549os@hzvpu.rqh> References: <990d094b-4733-492b-83f2-8014d51658c5@Spark> <046d83a6-d4c5-4c01-99ed-57b83d555b86@Spark> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="-1463808767-153765119-1698263580=:13777" Message-ID-Hash: KYK2C25Y5BM5DR77ACGJQCUIB65BQEB2 X-Message-ID-Hash: KYK2C25Y5BM5DR77ACGJQCUIB65BQEB2 X-MailFrom: adityam@umich.edu X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list Reply-To: mailing list for ConTeXt users Subject: [NTG-context] Re: Combining python and lua List-Id: mailing list for ConTeXt users Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---1463808767-153765119-1698263580=:13777 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Wed, 25 Oct 2023, Alexandre Christe wrote: > Dear list, >=20 > I=E2=80=99d like to know the best approach to make this a bit more usable= =2E I=E2=80=99m trying to typeset a table with sin/cos/tan values. I=E2=80= =99d like to be able to convert the angles in degrees into radians (with ma= th notation) and to compute the trigonometric function leading to sin(pi/4)= =3D 1/2, or cos(pi/6) =3D sqrt(3)/2 and display it in math mode. >=20 > Here=E2=80=99s my current MWE, where I fail to convert the angles in radi= ans=20 there is math.sind, cosd, etc. for computing sin for angle in degrees. The = implementation is l-math.lua is: local pipi =3D 2*math.pi/360 function math.sind(d) return sin(d*pipi) end function math.cosd(d) return cos(d*pipi) end function math.tand(d) return tan(d*pipi) end > and fail to display the result in symbolic form. Context doesn't do symbolic math. You can try checking if one of the symbol= ic math libraries in lua provides all the features that you want. > One possible way would be to use Python and the t-filter module, like thi= s This can work as follows. Take the array of angles, and convert them to the= desired format in python and write them to a temp file. Read that temp fil= e in lua and typeset it as you want. Another option is an old proof of concept by Luigi: https://github.com/bast= ibe/lunatic-python which allowed two-way communication between python and l= uatex. Not sure if it still works. Aditya ---1463808767-153765119-1698263580=:13777 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 / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________ ---1463808767-153765119-1698263580=:13777--