summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2011-08-31 11:11:31 +0200
committerEric Schulte <schulte.eric@gmail.com>2011-08-31 06:09:36 -0600
commit77537073a1e1d5c09180e7eae3775ae5cdde71fd (patch)
treeddf31b797cebb8d855c52b3de8beadf2a76bfb16
parentcae9f947beb5f529569a7eb33b460e670fb8ff97 (diff)
downloadorg-mode-77537073a1e1d5c09180e7eae3775ae5cdde71fd.tar.gz
ob-asymptote: full support for uni-dimensional lists
* lisp/ob-asymptote.el (org-babel-asymptote-var-to-asymptote): recognize non-nested lists as uni-dimensional arrays.
-rw-r--r--lisp/ob-asymptote.el18
1 files changed, 10 insertions, 8 deletions
diff --git a/lisp/ob-asymptote.el b/lisp/ob-asymptote.el
index 89aecb7..f90bb85 100644
--- a/lisp/ob-asymptote.el
+++ b/lisp/ob-asymptote.el
@@ -97,9 +97,8 @@ Asymptote does not support sessions"
The elisp value PAIR is converted into Asymptote code specifying
a variable of the same value."
(let ((var (car pair))
- (val (if (symbolp (cdr pair))
- (symbol-name (cdr pair))
- (cdr pair))))
+ (val (let ((v (cdr pair)))
+ (if (symbolp v) (symbol-name v) v))))
(cond
((integerp val)
(format "int %S=%S;" var val))
@@ -107,14 +106,17 @@ a variable of the same value."
(format "real %S=%S;" var val))
((stringp val)
(format "string %S=\"%s\";" var val))
+ ((and (listp val) (not (listp (car val))))
+ (let* ((type (org-babel-asymptote-define-type val))
+ (fmt (if (eq 'string type) "\"%s\"" "%s"))
+ (vect (mapconcat (lambda (e) (format fmt e)) val ", ")))
+ (format "%s[] %S={%s};" type var vect)))
((listp val)
- (let* ((dimension-2-p (cdr val))
- (dim (if dimension-2-p "[][]" "[]"))
- (type (org-babel-asymptote-define-type val))
+ (let* ((type (org-babel-asymptote-define-type val))
(array (org-babel-asymptote-table-to-array
val type
- (if dimension-2-p '(:lstart "{" :lend "}," :llend "}")))))
- (format "%S%s %S=%s;" type dim var array))))))
+ '(:lstart "{" :lend "}," :llend "}"))))
+ (format "%S[][] %S=%s;" type var array))))))
(defun org-babel-asymptote-table-to-array (table type params)
"Convert values of TABLE into a string of an asymptote array.