>From 82ae786a8ed1248a62912272edec6f8fa7df4d12 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 31 Aug 2011 11:11:31 +0200 Subject: [PATCH 1/2] 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. --- lisp/ob-asymptote.el | 18 ++++++++++-------- 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. -- 1.7.6.1