Code Red > AutoLISP (Vanilla / Visual)

vl-some one?

(1/4) > >>

Sdoman:
Question:

What does the vl-some function do and how would you use it?

I just came across this function and don't understand the help file. Thanks!
 

LE:
VL-SOME is useful, to find a value and stop without continue evaluating.... [plain-english I think]

i.e.:

- You, have a file with all your project paths
- From that you make a list of paths
- Then you look for the drawing "test.dwg"
- Let say the paths list is of 100 items and "test.dwg" is in the path item 4
- With vl-some we can do the follwing and stop, at the moment the path correspond to your file.

HTH



--- Code: ---;; projectpaths.txt
;;
;; C:\routines\
;; M:\_standard\3Blocks\04Mason\Stone\
;; C:\test\__AEC\AR\B\ARCH\
;; etc....

;; usage: (file-finder [file name] [extension] [list of paths])
;; return: full path and file name
;;
;; if no extension is provided by default uses: ".dwg"
;;
;; (file-finder
;;   "test"
;;   ".dwg"
;;   '("C:\\routines\\" "M:\\Blocks\\Stone\\" "C:\\test\\"))
;;
;; "C:\\routines\\test.dwg"
;;
(defun file-finder  (FileName Ext OfficePaths)
  (vl-some
    '(lambda (Path)
       (findfile (strcat Path
    (vl-filename-base FileName)
    (cond (Ext)
          (".dwg")))))
    OfficePaths))

--- End code ---

Sdoman:
Thanks LE!  Good example. 

So if I understand correctly, the first argument to vl-some is a test function to be applied to the second argument which is a list of values.  Vl-some passes the first element of the list to the test function and if the result is not-nill then stops.  Otherwise, it passes the next element of the list and so one until the end of the list.

The help file hinted that more then one list could be supplied.  Can you or anyone show an example using two or more lists please?

Thanks!

LE:

--- Quote from: Steve Doman on November 26, 2005, 11:18:55 AM ---Thanks LE!  Good example. 

So if I understand correctly, the first argument to vl-some is a test function to be applied to the second argument which is a list of values.  Vl-some passes the first element of the list to the test function and if the result is not-nill then stops.  Otherwise, it passes the next element of the list and so one until the end of the list.

The help file hinted that more then one list could be supplied.  Can you or anyone show an example using two or more lists please?

Thanks!

--- End quote ---

Yes.... I have more functions using vl-some.... I'll tried to post some more.... later

Fatty:

--- Quote ---
Yes.... I have more functions using vl-some.... I'll tried to post some more.... later

--- End quote ---

I think there are two very interesting themes begin owing to following functions:
'vl-some'
and
'vl-every'
which considerably accelerate processing and sorting of lists that are used
My highest gratitude if you shine this dark side of the Moon

Thank you,

Regards,

Fatty

Navigation

[0] Message Index

[#] Next page

Go to full version