• progeCAD in French Language
  • progeCAD in Spanish Language
  • progeCAD in English Language

(nth)

(nth)

(nth integer list)


Determine the nth item in the list.


Like car and cdr, the function nth is used to separate an element from a list. This function is much easier to use in long lists to isolate a single element.

The argument integer represents the number of the item to isolate. Remember that the first item in the list is numbered 0, so that when you want the third item you use 2. When integer is larger than the number of items (actually, number - 1 items) in the list, the nth function returns nil.

Examples

Code Returns
(setq b '(1 2 3 4 5 4 3 2 1)) (1 2 3 4 5 4 3 2 1)
(nth 4 b) 5
(setq c '("one" "two" "three" "four")) (one two three four)
(nth 2 c) three
(nth 5 c) nil

(last list)

(length list)

(reverse list)

(setq symbol1 statement1 [symbol2 statement2] ...)

LISP Compatibility

Programming Overview of LISP (LISt Processing) Language

 
DWG is the native file format for Autodesk AutoCAD®. Autodesk and AutoCAD are registered trademarks or trademarks of Autodesk, Inc. in the USA and/or other countries. progeSOFT and progeCAD are registered trademarks or trademarks of progeCAD s.r.l. in the USA and/or other countries.