From: Eric Schulte <schulte.eric@gmail.com>
To: Nicolas Goaziou <n.goaziou@gmail.com>
Cc: "András Major" <andras.g.major@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table
Date: Mon, 29 Aug 2011 12:02:11 -0600 [thread overview]
Message-ID: <87hb506qqk.fsf@gmail.com> (raw)
In-Reply-To: <87vctgi0ve.fsf@gmail.com> (Nicolas Goaziou's message of "Mon, 29 Aug 2011 19:27:49 +0200")
[-- Attachment #1: Type: text/plain, Size: 1907 bytes --]
Nicolas Goaziou <n.goaziou@gmail.com> writes:
> Hello,
>
> Eric Schulte <schulte.eric@gmail.com> writes:
>
>> I don't know asymptote well enough to know if you would /always/ want a
>> heterogeneous table to be converted to all strings, or if there would
>> ever be a case where you would want mixed types in a table.
>
> There are no mixed types arrays in Asymptote, hence the problem of the
> OP. You can choose between int[][], real[][] or string[][] (and other
> types specific to Asymptote and, as such, irrelevant here), but you
> never want an heterogeneous table.
>
> So, the real question is: what should Org do when an user tries to fit
> a mixed array into an Asymptote var? Until now, it was throwing an
> error. With this patch, _one_ string in the table will trigger the
> string type for every other cell.
>
> But this kind of an hidden feature. The user has to be aware that, under
> some circumstances, ints in his table will become strings.
>
> On the other hand, an user knowing he can't mix types in Asymptote (as
> he should) can't do much about it, as far as I know.
>
> As I said in this thread, an elegant solution would be to have a way to
> specify Babel to output tables of strings easily:
>
> | x | "1" | "2" | "3" |
> | y | "1" | "4" | "9" |
>
> That would be the less surprising, as the user would get the type he
> sees in his table.
>
Given that asymptote can not make use of heterogeneous tables, it seems
that it would be easiest to simply silently converted any table
containing a single string element to a table of all strings. I've just
applied your previous patch (thanks for the patch!). If this proves
confounding in the future we can always revisit the decision.
Additionally, I've just added a new function to the library of babel
which can be used to convert all elements of a table to strings. It is
not needed here, but it could be useful in the future.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: all-to-string.org --]
[-- Type: text/x-org, Size: 714 bytes --]
** Convert every element of a table to a string
#+tblname: hetero-table
| 1 | 2 | 3 |
| a | b | c |
#+source: all-to-string
#+begin_src emacs-lisp :var tbl='()
(defun all-to-string (tbl)
(if (listp tbl)
(mapcar #'all-to-string tbl)
(if (stringp tbl)
tbl
(format "%s" tbl))))
(all-to-string tbl)
#+end_src
#+begin_src emacs-lisp :var tbl=hetero-table
(mapcar (lambda (row) (mapcar (lambda (cell) (stringp cell)) row)) tbl)
#+end_src
#+results:
| nil | nil | nil |
| t | t | t |
#+begin_src emacs-lisp :var tbl=all-to-string(hetero-table)
(mapcar (lambda (row) (mapcar (lambda (cell) (stringp cell)) row)) tbl)
#+end_src
#+results:
| t | t | t |
| t | t | t |
[-- Attachment #3: Type: text/plain, Size: 79 bytes --]
Cheers -- Eric
>
>
> Regards,
--
Eric Schulte
http://cs.unm.edu/~eschulte/
next prev parent reply other threads:[~2011-08-29 18:02 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-29 8:00 Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table Major A
2011-08-29 8:47 ` Nicolas Goaziou
2011-08-29 9:12 ` András Major
2011-08-29 9:50 ` Nicolas Goaziou
2011-08-29 10:42 ` András Major
2011-08-29 12:50 ` Nicolas Goaziou
2011-08-29 16:35 ` Nicolas Goaziou
2011-08-29 16:52 ` Eric Schulte
2011-08-29 17:27 ` Nicolas Goaziou
2011-08-29 18:02 ` Eric Schulte [this message]
2011-08-29 18:50 ` András Major
2011-08-29 19:02 ` Eric Schulte
2011-08-29 19:11 ` Nick Dokos
2011-08-30 19:12 ` András Major
2011-08-30 19:34 ` Eric Schulte
2011-08-30 20:45 ` András Major
2011-08-30 20:55 ` Eric Schulte
2011-08-31 6:48 ` András Major
2011-08-31 8:17 ` Nick Dokos
2011-08-31 9:35 ` Nicolas Goaziou
2011-08-31 12:14 ` Eric Schulte
2011-08-29 9:05 ` Nick Dokos
2011-08-29 9:40 ` András Major
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87hb506qqk.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=andras.g.major@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=n.goaziou@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.