From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [babel] Code for simple set-operations on two tables. Asking for some input. Date: Tue, 27 Dec 2011 13:53:27 -0700 Message-ID: <87sjk5ka7s.fsf@gmx.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:59183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rfe1k-0002Et-Ot for emacs-orgmode@gnu.org; Tue, 27 Dec 2011 15:53:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rfe1j-0007TA-Dm for emacs-orgmode@gnu.org; Tue, 27 Dec 2011 15:53:40 -0500 Received: from mailout-us.gmx.com ([74.208.5.67]:33977 helo=mailout-us.mail.com) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Rfe1j-0007RG-6T for emacs-orgmode@gnu.org; Tue, 27 Dec 2011 15:53:39 -0500 In-Reply-To: (Marc-Oliver Ihm's message of "Mon, 26 Dec 2011 12:00:49 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Marc-Oliver Ihm Cc: emacs-orgmode@gnu.org Marc-Oliver Ihm writes: > Hello, > > Please find attached the elisp-file and a tutorial (as an org-file) for org-babel-table-proc. > > It provides some simple set-operations (mostly merge and intersect), > which treat org-mode tables as sets. > > An example for merging two tables would be: > >> #+name: lower >> | 2 | b | >> | 4 | d | >> | 5 | e | >> | 6 | h | >> >> #+name: upper >> | 1 | A | >> | 3 | C | >> | 4 | D | >> | 10 | J | >> | 2 | B | >> >> #+begin_src emacs-lisp :var t1=lower :var t2=upper >> (babel-table-proc-merge t1 t2) >> #+end_src >> >> #+results: >> | 1 | | A | >> | 2 | b | B | >> | 3 | | C | >> | 4 | d | D | >> | 5 | e | | >> | 6 | h | | >> | 10 | | J | > > which merges the two input tables lower and upper into a single table, > even, if they do not have all keys (from the first column) in common. > In general this merges information from two different sources without > loosing anything. > > The package org-babel-table-proc provides these and a few other > operations, but definitely still needs some debugging and polishing. > > However, before finishing this work, I would like to ask, if something > like this is already present in babel or the library of babel ? > Nothing like this is currently available in the library of Babel. I do think that such a library of "indexed set operations" would be a useful addition to the library. As for packaging, although it may be more comfortable to develop these functions in the manner you are currently using (with side-by-side .el and .org files), when it comes time to add these code blocks to the library of babel, I would recommend *combining* the elisp source and the explanatory prose as a single new subtree in the existing org-babel-library-of-babel.org file. Rather than exposing these functions as elisp functions they could be exposed as Babel code blocks, e.g., #+begin_src emacs-lisp :var t1=lower :var t2=upper (babel-table-proc-merge t1 t2) #+end_src would instead become #+call: proc-merge(lower, upper) > > Also, I am not sure, which prefix to use for packages and functions; > is org-babel-table-proc the right name or can it be shortened to > ob-table-proc. > If you package these as code blocks in the library of babel then there is no issue of prefixing, just pick meaningful names for the code blocks and don't define any global elisp functions. > > Any input would be very welcome ! > I hope the above helps, please let me know if I have been unclear or if you have any other questions. I look forward to your patch! Cheers, > > With kind regards, Marc-Oliver Ihm > > -- Eric Schulte http://cs.unm.edu/~eschulte/