[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typ
From: |
Nicolas Goaziou |
Subject: |
Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table |
Date: |
Mon, 29 Aug 2011 14:50:53 +0200 |
András Major <address@hidden> 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
- [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table, Major A, 2011/08/29
- Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table, Nicolas Goaziou, 2011/08/29
- Re: [O] Bug: Babel: asymptote: erroneous conversion o f heterogeneous-typed table, András Major, 2011/08/29
- Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table, Nicolas Goaziou, 2011/08/29
- Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table, András Major, 2011/08/29
- Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table,
Nicolas Goaziou <=
- Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table, Nicolas Goaziou, 2011/08/29
- Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table, Eric Schulte, 2011/08/29
- Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table, Nicolas Goaziou, 2011/08/29
- Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table, Eric Schulte, 2011/08/29
- Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table, András Major, 2011/08/29
- Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table, Eric Schulte, 2011/08/29
- Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table, Nick Dokos, 2011/08/29
- Re: [O] Bug: Babel: asymptote: erroneous conversi on of heterogeneous-typed table, András Major, 2011/08/30
- Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table, Eric Schulte, 2011/08/30
- Re: [O] Bug: Babel: asymptote: erroneous conver sion of heterogeneous-typed table, András Major, 2011/08/30