0 Members and 1 Guest are viewing this topic.
... instead of writing all those functions by hand, using lots of copy-paste and manual edits (i.e. a great many chances of making mistakes) you use stuff like eval to write code which "writes" code . Of course it's not (yet) as powerful as those defmacro ideas in Common Lisp / Scheme, but it's "getting close"
Quote from: irneb on May 02, 2015, 04:56:56 AM... instead of writing all those functions by hand, using lots of copy-paste and manual edits (i.e. a great many chances of making mistakes) you use stuff like eval to write code which "writes" code . Of course it's not (yet) as powerful as those defmacro ideas in Common Lisp / Scheme, but it's "getting close" Ok, this is similar to what has been done in this thread:http://www.theswamp.org/index.php?topic=45900.msg511029#msg511029
My point is I used the vl-position trick to get index in list.Main use is to make sure a point is there or not.
_$ (QBench '((vl-position 9000 Test) (member 9000 Test) (IsInList 9000 Test) (vl-position 1000 Test) (member 1000 Test) (IsInList 1000 Test) (vl-position 5000 Test) (member 5000 Test) (IsInList 5000 Test)))Benchmarking ......... done for 32768 iterations. Sorted from fastest.Statement Increment Time(ms) Normalize Relative--------------------------------------------------------------------------------(VL-POSITION 9000 TEST) 32768 1763 1763 1.00(VL-POSITION 5000 TEST) 16384 1420 2840 1.61(VL-POSITION 1000 TEST) 16384 1887 3774 2.14(MEMBER 9000 TEST) 8192 1779 7116 4.04(ISINLIST 9000 TEST) 2048 1497 23952 13.59(MEMBER 5000 TEST) 2048 1857 29712 16.85(MEMBER 1000 TEST) 1024 1623 51936 29.46(ISINLIST 5000 TEST) 512 1747 111808 63.42(ISINLIST 1000 TEST) 256 1544 197632 112.10--------------------------------------------------------------------------------
For that particular situation vl-position is always faster.On list of a couple of hundred items, difference is marginal.As the list grows, it becomes very perceptible.
In that case, vl-position (on its own) would always be the fastest on average ... for that particular situation.