The above could alternatively be written:
(defun LM:data->xdata ( x )
(cond
( (= 'str (type x)) (list (cons (if (handent x) 1005 1000) x)))
( (= 'real (type x)) (list (cons 1040 x)))
( (= 'int (type x)) (list (cons (if (< -32769 x 32768) 1070 1071) x)))
( (= 'list (type x)) (append '((1002 . "{")) (apply 'append (mapcar 'LM:data->xdata x)) '((1002 . "}"))))
( (list (cons 1000 (vl-prin1-to-string x))))
)
)