From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] ob-ocaml: Support for pretty-printed outputs Date: Sun, 13 Oct 2019 09:48:17 +0200 Message-ID: <871rvhcchq.fsf@nicolasgoaziou.fr> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:47639) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJYcB-0000dU-Ac for emacs-orgmode@gnu.org; Sun, 13 Oct 2019 03:48:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJYc9-0008HI-Gv for emacs-orgmode@gnu.org; Sun, 13 Oct 2019 03:48:30 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:58761) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iJYc9-0008FI-AZ for emacs-orgmode@gnu.org; Sun, 13 Oct 2019 03:48:29 -0400 In-Reply-To: (Robert M. Kovacsics's message of "Fri, 04 Oct 2019 17:52:50 +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" To: "Robert M. Kovacsics" Cc: Org-mode Hello, "Robert M. Kovacsics" writes: > Subject: [PATCH] ob-ocaml: Support for pretty-printed outputs > > E.g. the following snippet produces multiple lines of output, due to > pretty-printing > > #+BEGIN_SRC ocaml :exports code :eval no-export :results verbatim > (* Note, no need to have parentheses around sqrt, as > application binds the tightest *) > let rec gamma n = if n = 0 > then (1.0 +. sqrt 5.0) /. 2.0 > else 1.0 /. (gamma (n-1) -. 1.0) > > let nums = List.map gamma (List.init 5 (fun x -> x)) > #+END_SRC > > #+NAME: gamma-tbl > #+RESULTS[1fd6a3e846afdef51350eb6d7ba15c6844ccc14e]: > : val gamma : int -> float = > : val nums : float list = > : [1.6180339887498949; 1.61803398874989468; 1.61803398874989535; > : 1.61803398874989357; 1.61803398874989823] > > (In reality this would have 50 or so outputs, point being mathematically > it shouldn't change, but due to floating point errors it does.) > > The regexp has the following problems: > > - The "." in group 5 (as-was) doesn't match new-lines, so it only > matches the first line, e.g. as a list > : - [1.6180339887498949, 1.61803398874989468, 1.61803398874989535, > > - When using "\\(.\\|\n\\)", it includes the starting indentation of the > list, which makes org-babel-script-escape choke (called from > org-babel-ocaml-read-list, from org-babel-ocaml-parse-output, from > org-babel-execute:ocaml, the code being modified. Since no-one commented your patch, I applied it. I added TINYCHANGE cookie at the end of the commit message, since I don't know if you signed the FSF papers already. Thank you for your contribution! Regards, -- Nicolas Goaziou