Author Topic: Export coordinates of points in order  (Read 7448 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Re: Export coordinates of points in order
« Reply #15 on: December 06, 2011, 06:40:05 AM »
pts is list of xyz points... And it is written (vl-sort pts (function (lambda ...)))... But I was ab to ask why is vl-sort function dangerous to use like its written here :-o
M.R.

I think because the name of the routine is the same as the function name .  :wink:

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Export coordinates of points in order
« Reply #16 on: December 06, 2011, 07:16:21 AM »
Code: [Select]
(defun-q vl-sort (lst func)
   (mapcar
     '(lambda (x) (nth x lst))
      (vl-sort-i lst func)
   )
)

|;
;;; This will ensure that (vl-sort) does not remove
;;; elements that it sees as equal.

It seems that vl-sort is useful only if comparison is possible between each pair of elements of a list. If comparison is impossible (pair is equal by comparison values) seems that vl-sort removes one comparing element from list, I am guessing second one...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Export coordinates of points in order
« Reply #17 on: December 06, 2011, 07:30:31 AM »
Yes it removes duplicates, but I don't know witch ones...

Code: [Select]
Command: (vl-sort '((5 . 1) (9 . 3) (9 . 4) (9 . 5)) '(lambda (x y) (< (car x)
(car y))))
((5 . 1) (9 . 3) (9 . 4) (9 . 5))

Command: (vl-sort '((5 . 1) (9 . 3) (9 . 3) (9 . 3)) '(lambda (x y) (< (car x)
(car y))))
((5 . 1) (9 . 3) (9 . 3) (9 . 3))

Command: (vl-sort '(5 9 9 9 10 15) '(lambda (x y) (< x y)))
(5 9 10 15)

I can't make conclusion with these examples...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube