Received: from mx0.gmx.net (mx0.gmx.net [213.165.64.100]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with SMTP id q18IeCOE019675 for ; Wed, 8 Feb 2012 19:40:13 +0100 Received: (qmail 16069 invoked by alias); 8 Feb 2012 18:40:07 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 08 Feb 2012 18:40:06 -0000 Received: from relay.uni-heidelberg.de (EHLO relay.uni-heidelberg.de) [129.206.100.212] by mx0.gmx.net (mx104) with SMTP; 08 Feb 2012 19:40:06 +0100 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id q18IbQVv002609 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 8 Feb 2012 19:37:27 +0100 Received: from listserv.uni-heidelberg.de (localhost.localdomain [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id q18G1F0n009130; Wed, 8 Feb 2012 19:37:26 +0100 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 2014035 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Wed, 8 Feb 2012 19:37:26 +0100 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id q18IbQqS001498 for ; Wed, 8 Feb 2012 19:37:26 +0100 Received: from neptune.ucc.ie (neptune.ucc.ie [143.239.153.183]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id q18IbCn8002519 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 8 Feb 2012 19:37:18 +0100 Received: from csmvddesktop (csmvddesktop.ucc.ie [143.239.74.97]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: dongen) by neptune.ucc.ie (Postfix) with ESMTPSA id D2FCA20165 for ; Wed, 8 Feb 2012 18:37:36 +0000 (GMT) References: <20120203151218.GA30208@csmvddesktop> <4F2BFFA6.1020306@morningstar2.co.uk> <20120203155926.GA30436@csmvddesktop> <20120205160826.GA6939@csmvddesktop> <20120206054259.GB9462@csmvddesktop> <20120207183403.GA1694@csmvddesktop> <4F32A414.4060706@residenset.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.5.21 (2010-09-15) Message-ID: <20120208184203.GA10275@csmvddesktop> Date: Wed, 8 Feb 2012 18:42:03 +0000 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: dongen Subject: Re: Mapping Functions Versions for All and Some To: LATEX-L@listserv.uni-heidelberg.de In-Reply-To: <4F32A414.4060706@residenset.net> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-GMX-Antispam: 0 (eXpurgate); Detail=5D7Q89H36p7v2e6YIeqtw5m4ww1vaGEzmsEu6MPgeZYgJsVvgs2vc3Y0Pjkt6IFfnSTfR N3/tFIuXqQ2V69I9BGiwqCVu4QXor9qzm4jGWtLuQFFZtUH+3vTT57rLx2S4Bz8CJ+JhyeBqXpVP RyGy9wyc6Yl7dVlf8S/NkBpsG3Yzom/+fL2K9yzldIDSj3MIxWRM9hexq4=V1; X-Resent-By: Forwarder X-Resent-For: rainer.schoepf@gmx.net X-Resent-To: rainer@rainer-schoepf.de Status: R X-Status: X-Keywords: X-UID: 7034 * Lars Hellström [2012-02-08 17:34:28 +0100]: Hi Lars, : The problem with expandable caching is in _how_ one stores the : cached data. The elementary way of storing information in TeX is to : make an assignment, but an assignment is a command, and thus cannot : be performed at expand-time. The subset of TeX programming : techniques that are available at expand-only-time are quite unlike : imperative programming, and also (AFAICT) not so much supported by : the LaTeX3 kernel at the moment. One illustration of this is : provided by the suggested solution to the "Mapping Functions : Versions for All and Some" that are still in the title this thread: : it involved setting a flag variable. Setting a flag is an : assignment, so that solution would not do for an "All" or "Some" : predicate that had to be evaluated at expand-time. Thanks. I've almost implemented a naive implementation of a fibonacci macro that uses the ideas I explained in my email to Bruno. I think it should be possible to _automate_ this kind of implementation for similar computations. (Having to write this by hand is cumborsome and prone to errors.) : This does not mean it is impossible to do at expand-time, but one : has to employ a different set of programming techniques when doing : it: mostly techniques from functional programming, and when nothing : else helps resort to combinatory logic (as the equivalent and more : traditional lambda calculus requires a lambda operator, which again : is not available at expand-time in TeX). Since caches can be : implemented in lambda calculus, one can make an expand-time cache in : TeX, but the details are not exactly easy to get right. Thanks. I'm only starting to scratch at the surface that's called expansion. As soon as April comes I'll study it in more detail. At the moment, I'm mainly learning the expl3 API. : FWIW, making something expandable that could cache arbitrary amounts : of data was a motivating use-case when I set out to write that : 2-3-tree package I've mentioned earlier. It is feasible to use (or : will be, once finished), but I think the programming style will take : many quite some time to get used to. Or it may be possible to use code generation to take (simple) bits of TeX and turn them into caching equivalents that use the package. : >This seems very doable and I think it's possible to do it in a time complexity : >that is at most O( c^2 ), where c is the number of things that have to be cached. : : You're thinking recursions of bounded length here? Be aware that : even with a cache of fixed length it may be a nontrivial problem to : write a TeX macro that will access the right elements; one tends to : run out of arguments (#9 is the last there is). Writing correct code : that automatically defines the necessary macro is even trickier. : : >It's also possible to optimise the cache, in the sense that lookups for : >frequently looked up items are more efficient. : : If computations are not restricted to expand-time, then any access : is just O(1), so no need to optimise. But if you want to be building : the cache at expand-time then you're into very deep waters. : : >I'll try and implement this for a toy example. If it proves successful, : : Considering your performance so far, a success at that would : surprise me; more likely you'll end up producing a piece of code : that doesn't work as intended and then asking everyone why it : doesn't. Learn to walk before you run. :-) The performance is pathetic, compared to an equivalent implementation in Java. I was surprised about howw much more slow it is. Hopefully caching will improve it. Anyway, I'll let you know when I have some more details. (It may even turn out that you're right and that the complexity of implementation turns out impossible to handle.) Regards, Marc van Dongen