明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1099|回复: 4

如何给表加上括号”()“!

[复制链接]
发表于 2009-4-7 10:26 | 显示全部楼层 |阅读模式
比如我有一个表 :((A B)(C D)(E F)),怎么样才能变成:(((A B)(C D)(E F))),谢谢啊!
发表于 2009-4-7 12:22 | 显示全部楼层
(mapcar 'list '((A B) (C D) (E F)))
发表于 2009-4-7 13:53 | 显示全部楼层
  1. (defun c:test (/ a1 el str)
  2.   (setq    txt5 (ukword
  3.            1
  4.            "1 2 3 4 5 6 7 8 9"
  5.            "\n请选择括号形式:1-()/2-()/3-{}/4-[]/5-〔〕/6-「」/7-『』/8-〖〗/9-【】"
  6.            txt5
  7.          )
  8.     a1   (car (entsel "\n请选择文字 : "))
  9.     el   (entget a1)
  10.     str  (dxf 1 el)
  11.   )
  12.   (khxs)
  13.   (setq    a1 (subst (cons 1 str) (ASSOC 1 el) el)
  14.   )
  15.   (entmod a1)
  16.   (princ)
  17. )
  18. (defun dxf (code elist) (cdr (assoc code elist)))
  19. (defun khxs ()
  20.   (cond    ((= txt5 "1") (setq str (strcat "(" str ")")))
  21.     ((= txt5 "2") (setq str (strcat "(" str ")")))
  22.     ((= txt5 "3") (setq str (strcat "{" str "}")))
  23.     ((= txt5 "4") (setq str (strcat "[" str "]")))
  24.     ((= txt5 "5") (setq str (strcat "〔" str "〕")))
  25.     ((= txt5 "6") (setq str (strcat "「" str "」")))
  26.     ((= txt5 "7") (setq str (strcat "『" str "』")))
  27.     ((= txt5 "8") (setq str (strcat "〖" str "〗")))
  28.     ((= txt5 "9") (setq str (strcat "【" str "】")))
  29.     (t (setq str (strcat "(" str ")")))
  30.   )
  31. )
  32. (defun ukword (bit kwd msg def / inp)
  33.   (if (and def (/= def ""))
  34.     (setq msg (strcat "\n" msg "<" def ">:")
  35.       bit (* 2 (fix (/ bit 2)))
  36.     )
  37.     (setq msg (strcat "\n" msg ":"))
  38.   )
  39.   (initget bit kwd)
  40.   (setq inp (getkword msg))
  41.   (if inp
  42.     inp
  43.     def
  44.   )
  45. )
  46. (defun c:jkh()(c:test))
发表于 2009-4-7 14:11 | 显示全部楼层

(setq a '((1 2) (3 4)))

(list a)->(((1 2) (3 4)))

 楼主| 发表于 2009-4-7 14:18 | 显示全部楼层

终于找到思路了,谢谢上面的bobby、samshs、caoyin,呵呵!

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-7-4 12:22 , Processed in 0.163606 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表