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.
This commit is contained in:
parent
cae9f947be
commit
77537073a1
|
@ -97,9 +97,8 @@ Asymptote does not support sessions"
|
||||||
The elisp value PAIR is converted into Asymptote code specifying
|
The elisp value PAIR is converted into Asymptote code specifying
|
||||||
a variable of the same value."
|
a variable of the same value."
|
||||||
(let ((var (car pair))
|
(let ((var (car pair))
|
||||||
(val (if (symbolp (cdr pair))
|
(val (let ((v (cdr pair)))
|
||||||
(symbol-name (cdr pair))
|
(if (symbolp v) (symbol-name v) v))))
|
||||||
(cdr pair))))
|
|
||||||
(cond
|
(cond
|
||||||
((integerp val)
|
((integerp val)
|
||||||
(format "int %S=%S;" var val))
|
(format "int %S=%S;" var val))
|
||||||
|
@ -107,14 +106,17 @@ a variable of the same value."
|
||||||
(format "real %S=%S;" var val))
|
(format "real %S=%S;" var val))
|
||||||
((stringp val)
|
((stringp val)
|
||||||
(format "string %S=\"%s\";" var 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)
|
((listp val)
|
||||||
(let* ((dimension-2-p (cdr val))
|
(let* ((type (org-babel-asymptote-define-type val))
|
||||||
(dim (if dimension-2-p "[][]" "[]"))
|
|
||||||
(type (org-babel-asymptote-define-type val))
|
|
||||||
(array (org-babel-asymptote-table-to-array
|
(array (org-babel-asymptote-table-to-array
|
||||||
val type
|
val type
|
||||||
(if dimension-2-p '(:lstart "{" :lend "}," :llend "}")))))
|
'(:lstart "{" :lend "}," :llend "}"))))
|
||||||
(format "%S%s %S=%s;" type dim var array))))))
|
(format "%S[][] %S=%s;" type var array))))))
|
||||||
|
|
||||||
(defun org-babel-asymptote-table-to-array (table type params)
|
(defun org-babel-asymptote-table-to-array (table type params)
|
||||||
"Convert values of TABLE into a string of an asymptote array.
|
"Convert values of TABLE into a string of an asymptote array.
|
||||||
|
|
Loading…
Reference in New Issue