0 Members and 1 Guest are viewing this topic.
;; 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))
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!
Yes.... I have more functions using vl-some.... I'll tried to post some more.... later
(defun some ( foop lst / result ) (if (listp foop) (setq foop (eval foop))) (vl-catch-all-apply '(lambda ( ) (foreach x lst (if (foop x) (progn (setq result t) (exit) ) ) ) ) ) result)(defun every ( foop lst / failed ) (if (listp foop) (setq foop (eval foop))) (vl-catch-all-apply '(lambda ( ) (foreach x lst (if (null (foop x)) (progn (setq failed t) (exit) ) ) ) ) ) (null failed))
(some '(lambda (x) (eq 'str (type x))) '("a" "b" 42 "d" "e"))
(every '(lambda (x) (eq 'str (type x))) '("a" "b" 42 "d" "e"))
(some '(lambda (x) (print x) (eq 'str (type x))) '("a" "b" 42 "d" "e"))
(every '(lambda (x) (print x) (eq 'str (type x))) '("a" "b" 42 "d" "e"))
(defun some (l / term) (mapcar '(lambda (x) (if x (setq term t))) l) term)
(some (mapcar '(lambda (x) (and (equal (car x) (car pt) 0.0001) (equal (cadr x) (cadr pt) 0.0001) (equal (caddr x) (caddr pt) 0.0001))) lst))
(vl-some '(lambda (x) (and (equal (car x) (car pt) 0.0001) (equal (cadr x) (cadr pt) 0.0001) (equal (caddr x) (caddr pt) 0.0001))) lst)
(mapcar '(lambda (x y z) ...do something with x y z...)) (list1) (list2)(list3) )
Hi MPUndoubtedly, your teacher is the great person, and,it is true, that you are worthy the teacherI hope in 20 years I shall reach the same level as you nowRegards,Fatty
........................