So, should we make a library with a well tested, speed effective functions?
http://autocad.xarch.at/stdlib/html/ (http://autocad.xarch.at/stdlib/html/)
I'll give you a bit, tell me should I continue?The fact that Reini Urban's project was abandoned more than 10 years ago (and not picked up by 'the community') should make you think, but is in itself no reason to stop working on your project.
;;; (setq partLst '("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"))
;;; (setq testLst (append partLst partLst '(0) partLst partLst))
;;; (KGX_BenchMark '((vl-some 'numberp testLst) (divtiply_some 'numberp testLst) (roy_some_1 'numberp testLst) (roy_some_2 'numberp testLst)) 5000)
; Benchmarking .......... elapsed milliseconds / relative timing <5000 iterations>
; (VL-SOME 'NUMBERP TESTLST) ............ 16 / 8.81 <fastest>
; (ROY_SOME_2 'NUMBERP TESTLST) ......... 63 / 2.24
; (ROY_SOME_1 'NUMBERP TESTLST) ......... 93 / 1.52
; (DIVTIPLY_SOME 'NUMBERP TESTLST) ..... 141 / 1.00 <slowest>
Thanks Roy!Code: [Select]; Some improvements:
2. Consistent naming scheme? You now have predicate functions with names that do not end in '-p'.Which?
1. Do NOT be descriptive.
2. Try to keep variable names 3 letters or less.
3. Try to use a lower case 'l' as frequently as possible('l' is not the number one it is lowercase 'L').
Hi divtiply,
That was not directed toward you or any code you posted. It was a joke from a non-lisper who is not familiar with the language or the conventions and seeing snippets of code with 'a', 'l', etc... as variables.
An ex-lisper comment:
In all my past years spent (20+-) in the autolisp/vlisp world --- the only way or form I have seen to adopt a function as standard it is when these are added into the autolisp core. Anything out it will be way too difficult - will only be part of anyone's personal functions arsenal. Have seen so many try-outs -- ALL have failed.
Let see if this time not.
LE!
does anyone have routines from Looking Glass Microproducts? I had collected some from the very old cad shack website and it was very useful for learning and putting together my own routines. (also probably was not legitimately shared though... :-(
For example, ymg's ceil/floor functions [http://www.theswamp.org/index.php?topic=45379.msg505421#msg505421]:
consp2. Consistent naming scheme? You now have predicate functions with names that do not end in '-p'.Which?
Have seen so many try-outs -- ALL have failed.
They are standard CL names. As null, for example.
1.
Why look at CL?
(defun MyFunc (a) (if (numberp a) (1+ a)))
(roy_some_2 'MyFunc '("a" "b" "c" "d" 0)) => 1
(roy_some_2 'MyFunc '("a" "b" "c" 0)) => T
Why "cad....r" and not "nth #"
Roy,
Why "cad....r" and not "nth #" much easier to read a number then how many "d's" to use.
Bruce
(cadddr lst)
Because lst can be or become nil (nth) cannot be used here:(nth 3 nil) => Error
(cadddr nil) => nil
(vl-some 'atom nil) => nil
(divtiply_some 'atom nil) => T
(roy_some_1 'atom nil) => T
(roy_some_2_Revised 'atom nil) => nil
(roy_some_1_Revised_2 'atom nil) => nil
(roy_some_2_Revised_2 'atom nil) => nil
(vl-some 'atom '(nil)) => T
(divtiply_some 'atom '(nil)) => T
(roy_some_1 'atom '(nil)) => T
(roy_some_2_Revised 'atom '(nil)) => nil
(roy_some_1_Revised_2 'atom '(nil)) => T
(roy_some_2_Revised_2 'atom '(nil)) => T
(vl-some 'numberp '(nil nil 0 . 0)) => T
(divtiply_some 'numberp '(nil nil 0 . 0)) => T
(roy_some_1 'numberp '(nil nil 0 . 0)) => T
(roy_some_2_Revised 'numberp '(nil nil 0 . 0)) => Error
(roy_some_1_Revised_2 'numberp '(nil nil 0 . 0)) => T
(roy_some_2_Revised_2 'numberp '(nil nil 0 . 0)) => T
(vl-some 'numberp '(nil nil . 0)) => nil
(divtiply_some 'numberp '(nil nil . 0)) => Error
(roy_some_1 'numberp '(nil nil . 0)) => Error
(roy_some_2_Revised 'numberp '(nil nil . 0)) => Error
(roy_some_1_Revised_2 'numberp '(nil nil . 0)) => nil
(roy_some_2_Revised_2 'numberp '(nil nil . 0)) => nil
do you know if OpenLisp from your last post supports DCL use.DCL is unique to AutoCAD and some other .dwg software. So the answer is: No.
divtiply,
I suggest you test your so called "correct implementation" of ceil and floor function.
(defun floor (num / n)
(if (zerop (- num (setq n (fix num))))
n
(if (minusp num) (1- n) n)))
(defun ceiling (num / n)
(if (zerop (- num (setq n (fix num))))
num
(if (minusp num) n (1+ n))))
But your new code is faster.Well I leave you guys here..... want to stay in the lisp world - good --- and yes autolisp it is GREAT --- but have his limitations.
Well I leave you guys here..... want to stay in the lisp world - good --- and yes autolisp it is GREAT --- but have his limitations.I'm not sure how you want us to take this. But your samples aren't showing how C#/C++ is "better" than AutoLisp. It's just showing that there are already libraries you can use built into it. It wasn't always the case, the Math lib was an addon to C++, prior to that C/C++ programmers had to roll their own Ceil/floor functions too (it was actually one of the exercises I had to do in my programming degree - implement some standard math functions as a library in C++).
Yes, me too :lol: ... that is the main thing isn't it?
I look forward to seeing the implementation and documentation.
This entire thread is actually about implementing those libs so us AutoLispers have the use of them as well (instead of needing to design our own).
@ irneb and divtiply:Many things :o most notably:
What would it take to get this off the ground?
...I come from a background in lisp too...Actually I came from the other side: Basic, Pascal, Java & C++ first, AutoLisp became like a drug after that, then I started looking at all the other Lisps and literally (note TRUE use of the word) fell in love with it. Thanks I'll take a look at that thread also.
... < >I wish I knew where to GIT that. :wink: :wink:
Actually I came from the other side: Basic, Pascal, Java & C++ first, AutoLisp became like a drug after that, then I started looking at all the other Lisps and literally (note TRUE use of the word) fell in love with it. Thanks I'll take a look at that thread also.
Wow --- That's interesting - Hope and guess you still use at least the C++ and have that advantage. I am glad that I am out of lisp as I used to.... still can do some minor stuff when needed.Actually I despised C++, I try to avoid it as much as possible - did then (mid '90s) and still feel the same. I actually preferred Java and Pascal, so C# came nearly naturally to me (it's so close to Java as to make next to no difference). None of them (however) gives me the same sense of accomplishment through absolute minimum input that Lisp does. But that's just me.
Have fun!
Actually I despised C++, I try to avoid it as much as possible - did then (mid '90s) and still feel the same. I actually preferred Java and Pascal, so C# came nearly naturally to me (it's so close to Java as to make next to no difference). None of them (however) gives me the same sense of accomplishment through absolute minimum input that Lisp does. But that's just me.I think it is a very widespread opinion, this is also one of the reasons for the success of Bricscad and their effort to make it compatible the maximum possible with VisualLisp. This is also demonstrated by the number of topics:
Posts TheSwamp
-------------------------
AutoLISP (Visual) 76919
VB(A) 8467
.NET 24517
ARX Programming 2745
General Programming 7244
Topics TheSwamp Autodesk
-----------------------------------
AutoLISP (Visual) 6831 1842
VB(A) 910 801
.NET 2774 271
ARX Programming 335 304
General Programming 783
It seems that the topics of Autodesk begin by 1999, but many have been lost, especially of AutoLISP.
Actually I despised C++, I try to avoid it as much as possible - did then (mid '90s) and still feel the same.