emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: "András Major" <andras.g.major@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Bug: Babel: asymptote: erroneous conversion	of heterogeneous-typed table
Date: Mon, 29 Aug 2011 14:50:53 +0200	[thread overview]
Message-ID: <87mxesjs9e.fsf@gmail.com> (raw)
In-Reply-To: <loom.20110829T123802-490@post.gmane.org> ("András Major"'s message of "Mon, 29 Aug 2011 10:42:45 +0000 (UTC)")

András Major <andras.g.major@gmail.com> writes:

>> Why? You can always write an intermediary step to "stringify" every
>> cell. Choose your language. Nick Dokos showed you one way.
>
> Apparently, only if you set a global/per-user option in .emacs or suchlike,
> which I think is a bad way of doing it.
-----
#+tblname: mixed-types
|1|x|5|
|3|y|4|

#+source: stringify(table=mixed-types)
#+begin_src emacs-lisp
(concat "string[][] myvar={{"
        (mapconcat
         (lambda (row)
           (when (listp row)
             (concat (mapconcat (lambda (el) (format "\"%s\"" el)) row ",") "}")))
         table
         ",{")
        "};")
#+end_src

#+source: myplot
#+begin_src asymptote :noweb yes :file myplot.png
<<stringify(mixed-types)>>
unitsize(3cm);
draw((0,0)--(1,1));
#+end_src

#+results: myplot
[[file:myplot.png]]
----

It may be ugly, but it works.

> I don't think this is misuse in any way.  Consider a table which is a
> result of your research:  the columns are the maker (e.g., "Mazda"), the
> type (e.g., "MX-5"), engine displacement (a number), the mileage/fuel
> consumption (a number), etc., and I want to create some asymptote plot
> from this data.

How would you would you specify it to Asymptote? You can't.

You would probably use:

                string[][] cars={{"Mazda","MX-5","1.5"}};

And that's exactly my point: engine displacement may be a number, but
you would have to enter it as a string.

Though, you insist on being able to enter it as a number anyway, hoping
ob-asymptote will do the magic behind. How could it, since the language
can't itself?

Perhaps there should be a way in Babel (not specifically in Asymptote)
to output a table with raw strings. Because want you really want to use
is:

|"1"|"x"|"5"|
|"3"|"y"|"4"|


Regards,

-- 
Nicolas Goaziou

  reply	other threads:[~2011-08-29 12:51 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 [this message]
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
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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mxesjs9e.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=andras.g.major@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).