最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

lisp - AutoLISP -- Extracting a string from a List of Lists? - Stack Overflow

programmeradmin4浏览0评论

Working in AutoLISP. I am looking for a more elegant way to extract the second string in this list of lists...

(("FullName") ("Larry Paige"))

Currently using the following to extract desired data.

(setq _BAMOFO(nth 0 (nth 1 Result)))

Thank you.

Working in AutoLISP. I am looking for a more elegant way to extract the second string in this list of lists...

(("FullName") ("Larry Paige"))

Currently using the following to extract desired data.

(setq _BAMOFO(nth 0 (nth 1 Result)))

Thank you.

Share Improve this question edited yesterday Kyle Fleming asked yesterday Kyle FlemingKyle Fleming 113 bronze badges New contributor Kyle Fleming is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

2 Answers 2

Reset to default 0

Fully low-level way:

(car (car (cdr Result)))

Mixed way that is likely more readable, as it is closer to human intuition of what we want to get:

(car (nth 1 Result))

The most readable approach to me would be to be able to write:

(setq _BAMOFO (fullname result))

And you need to define a fullname accessor function. Then you do not really care about how it is implemented; nth is quite readable in my opinion.

(defun fullname (list)
  (nth 0 (nth 1 list)))

Or maybe you can find a more robust way to extract the name given the shape of your data, for example finding out the list the list that contains "FullName", that's not entirely clear to me if that makes sense in your context.

发布评论

评论列表(0)

  1. 暂无评论