Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with ESMTP id r1MB9w4H005336 for ; Fri, 22 Feb 2013 12:09:59 +0100 Received: from relay2.uni-heidelberg.de ([129.206.210.211]) by mx-ha.gmx.net (mxgmx005) with ESMTP (Nemesis) id 0M2oD8-1Uy4DZ2XcU-00siZH for ; Fri, 22 Feb 2013 12:09:52 +0100 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r1MB80kQ014790 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 22 Feb 2013 12:08:00 +0100 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r1MB023S008166; Fri, 22 Feb 2013 12:08:00 +0100 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 8086315 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Fri, 22 Feb 2013 12:07:59 +0100 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r1MB7xVY028691 for ; Fri, 22 Feb 2013 12:07:59 +0100 Received: from mail-oa0-f44.google.com (mail-oa0-f44.google.com [209.85.219.44]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id r1MB7thD025897 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Fri, 22 Feb 2013 12:07:58 +0100 Received: by mail-oa0-f44.google.com with SMTP id h1so478318oag.17 for ; Fri, 22 Feb 2013 03:07:54 -0800 (PST) X-Received: by 10.182.188.101 with SMTP id fz5mr622809obc.0.1361530775529; Fri, 22 Feb 2013 02:59:35 -0800 (PST) MIME-Version: 1.0 Received: by 10.76.22.6 with HTTP; Fri, 22 Feb 2013 02:59:15 -0800 (PST) X-Google-Sender-Auth: FzWZwYgzmY41TZhmCogN3EdDVTM Content-Type: multipart/mixed; boundary=f46d04462f8a39e90a04d64e16e2 X-Spam-Check-Skipped: Low on slaves (7) Message-ID: Date: Fri, 22 Feb 2013 11:59:15 +0100 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Michiel Helvensteijn Subject: Some ideas for the standard LaTeX3 modules (first: scanning functions) To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: Envelope-To: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; X-GMX-Antivirus: 0 (no virus found) X-UI-Filterresults: notjunk:1;V01:K0:YT9RWE6Vy4U=:eZi0gv7mM4WGl6LwmBYK7p PXVjETrfxurw6OBhjvRSEDOeHmUc6uFN3MOSNAj61sERjMHVXnUF/DEwsr7tfq0CeQ3g1qc +GVdUJZHEnnJJuPqiTfjDz+R9x+Bi520YtTLtj+OefmRnNxphNBrTWSrP1Mr4/chSGtUh+V fdYmAJk1RBhIP0lvKYf7shkYNYaGEQe5ZlE7hlzZedLnol3HjhCF1VWkncoTrRyIRqyoJvR nQeMiKwXUjUQI5kko9TAOT8k0U++LidE++RvXEhgeodWSTpiIT+VVcHQvw/u1AwOc+SpT8e zJijdFxyTc0cGQKD53kV0uatgLQj4gBkAahOCWW5xWbsBqEt+Ey433ssR/8j3hu2g4H8Jdi H1kwWx7l/yPwam/RD1hUaveDE1+5zdv3sseKZnAY0j5BrlDqIueXM+J3XvkLwRTvdUN/bJS k9XQQZj26W3ZlnqRyJ4aXywnfUKkADd5QH6aflKwSK6xyq5rWWGHRNUs0iomUEgN9VeF21z gw2cT5oYBcHsHc8zQjoeUuRyyQN8BpNK5Wgu8uNwx+xU1vjRrWP8c6ffMNIwRldgO5lzzp6 ffjLH3j/61ymWhFgf5j7OkHxpPgUAQ/YpYb2F/+v2uA5NoNJ70XiTqsYHlOSvopLwOem/yl z5ZV8V/mLL5SOjTPOdr3igtzG05yscEn8Ley/JvM1fVnpZXhh81WQwd5ODF4wPSV5HQyCGs Df1qkybxbxnEvHVEJCGZSiKWYtGUGO/bFsXValPuw1283vdPXInnj3OI7CMiMExLKxKnIYk 42cQiKfO2eD471rCr+N/enONE+I5yQQ7SyuXm+bVYurPZFNXve7X2rlGAogRUEBkU33YxA4 wo+MgtGGQcGLe5jflzpL3S8IqCe+zijItTirsfkWK0kWHTUPoOHTfIGlFociP8NO0YD7v/y V9it077vKTbZJ/HKUfhXvvjvnKRQaILAIfeC7AI44HQKDCi9Qix+Ip2qWhFN1QraW/BrLXZ 4fc5I4G/5fquUfdD5fbo72SMRkbGIZIp3KxhYGyf5gG4QAOHNgoztDG6L7A14XTpu21BTu2 DskbRgSZULBFloJhA2dZJv/soFhfbG9NiIpSSwSzz8JwICT0BAELY5Qdq8Q4/Y/29h7WJ7a dKJhHdiUeIDGOESojqr/sjFOCx8dS2SlUZQBzCzk5bDmAYw+ojUmL14G74BDzzOuGxEYbn+ IFdteiHtDBLb5RP8TguG8IaYCxOpdgKNrjx0VXRBJeWEkGZy+o1tkLt11bMzU3x8HgCkJRr prxdXQgxjuOT6BdQuY0ZZI1KvnrG94Zmyee6FJ4Qoi23s/hBrdAeBp4pHivQX7eICGdcpRk hkcKibPM35fefkS+nxllr848w/4HoW7K4tyweZWh9Q9/agAAtYApq+6x0wvvXRaDtJlMI0x xvW2JwaSE= X-UI-Loop:V01:ph5TpzAclPI=:oYlG2zmUc2VDBl+PcH/ysvvBR72j30HcZ6nYGte+DuA= Status: R X-Status: X-Keywords: X-UID: 7183 --f46d04462f8a39e90a04d64e16e2 Content-Type: text/plain; charset=ISO-8859-1 Hi all! I'm writing a large package in LaTeX3 right now (a rewrite of 'concepts' actually). I keep feeling the need to write some general purpose functions. For now I'm putting them as private functions in my package but I was wondering if they might not be a nice addition to the standard modules. However, even the example idea I mentioned in TeX.se chat seemed to be controversial, so I'll start with just that one. It's a small set of functions I wrote to scan ahead in the input stream to find modifiers and various delimited optional arguments without having to write auxiliary functions. First there's `\scan_tokens:nnw`, which scans ahead for any tokens that are in `#1`, grabs them and calls the (literal) function `#2` with the resulting token list as an argument. In my package I use them to grab digits and modifiers. Example: ------------------------------------------------------------ \ExplSyntaxOn \NewDocumentCommand \GrabDigits {} { \scan_tokens:nnw {1234567890} { (##1) } } \NewDocumentCommand \GrabModifiers {} { \scan_tokens:nnw {!*^} { (\tl_to_str:n{##1}) } } \ExplSyntaxOff \GrabDigits 76543xyz % yields (76543)xyz \GrabModifiers ^!^*$x$ % yields (^!^*)$x$ ------------------------------------------------------------ I've also written several related functions, like `\scan_tokens:nnFw` which calls `F` if no tokens were found. Also `\scan_delimited:NNnw` and `\scan_delimited:NNnFw` which are essentially an inline wrapper for an xparse `r` argument. I've attached a MWE. The implementation could be more efficient. I just felt like doing a recursive version. It would have been expandable if only `\peek_meaning_remove:NTF` was. :-) Please tell me what you think! -- www.mhelvens.net --f46d04462f8a39e90a04d64e16e2 Content-Type: application/x-tex; name="test.tex" Content-Disposition: attachment; filename="test.tex" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hdh7xnnh0 XGRvY3VtZW50Y2xhc3N7YXJ0aWNsZX0KCiUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUl JSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlCgpcdXNlcGFj a2FnZXtleHBsM30KXHVzZXBhY2thZ2V7eHBhcnNlfQoKJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUl JSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUK ClxFeHBsU3ludGF4T24KICAgIFxjc19uZXdfcHJvdGVjdGVkOk5wbiBcc2Nhbl90b2tlbnM6bk53 ICMxICMyIHsKICAgICAg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lJSUlJSUlJSUlJSUlJSUl JSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUKClxFeHBsU3ludGF4T24KICAgIFxOZXdEb2N1bWVu dENvbW1hbmQgXEdyYWJEaWdpdHMge30gewogICAgICAgIFxzY2FuX3Rva2VuczpubncgezEyMzQ1 Njc4OTB9IHsKICAgICAgICAgICAgKCMjMSkKICAgICAgICB9CiAgICB9CiAgICAKICAgIFxOZXdE b2N1bWVudENvbW1hbmQgXEdyYWJNb2RpZmllcnMge30gewogICAgICAgIFxzY2FuX3Rva2Vuczpu bncgeyEqXn0gewogICAgICAgICAgICAoXHRsX3RvX3N0cjpueyMjMX0pCiAgICAgICAgfQogICAg fQpcRXhwbFN5bnRheE9mZgoKJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUl JSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUKClxiZWdpbntkb2N1bWVu dH0KICAgIAogICAgXEdyYWJEaWdpdHMgNzY1NDN4eXoKICAgIAogICAgXEdyYWJNb2RpZmllcnMg XiFeKiR4JAogICAgClxlbmR7ZG9jdW1lbnR9Cg== --f46d04462f8a39e90a04d64e16e2--