Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

comp.cad.autocad AutoLISP FAQ (part 1/2) - general
Section - [10] Iteration with MAPCAR,...

( Part1 - Part2 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Restaurant inspections ]


Top Document: comp.cad.autocad AutoLISP FAQ (part 1/2) - general
Previous Document: [9] Recursion
Next Document: [11] S::STARTUP, My LISPs aren't loaded at startup anymore
See reader questions & answers on this topic! - Help others by sharing your knowledge
  Same as with recursion this is not a often asked question, but it's
  quite hard to understand too.
  Iterative statements in AutoLISP are: WHILE, REPEAT, FOREACH and
  MAPCAR. We use them widely in this FAQ code because they allow
  brief code.

  There's a short course in LAMBDA, QUOTE, MAPCAR... by Vladimir
  Nesterowsky:

  >>         "There are 14 paths and 12 pigs.
  >>         How can there be 24 ducks?"
  >> Is there a lisp command that will allow me to pick these
  >> lines of text, and recognize the number(s) in each line,
  >> in order to, say, raise each number by two?
  >> Leaving the sentence structure, etc, intact?
  This is one way. (I am sure there are many other ways)

  (defun mult2 (strng)          ; by Vladimir Nesterowsky
    (strlgather
      (mapcar
       '(lambda (s / n)
          (if (zerop (setq n (atof s)))
            s
            (rtos (* n 2))))
        (strlparse strng " "))  ; parse by spaces
      " "))                     ; gather back with spaces

 is explained at http://members.tripod.com/~vnestr/mapcar.txt

  ;;; flip rows and columns in a matrix
  (defun transpose(l)           ; by Doug Wilson
    (apply 'mapcar (cons 'list l)))

is explained at http://xarch.tu-graz.ac.at/autocad/lisp/transpose.002.html

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




Top Document: comp.cad.autocad AutoLISP FAQ (part 1/2) - general
Previous Document: [9] Recursion
Next Document: [11] S::STARTUP, My LISPs aren't loaded at startup anymore

Part1 - Part2 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
rurban@xarch.tu-graz.ac.at (Reini Urban)





Last Update March 27 2014 @ 02:11 PM