Author Topic: How to check if list a part of list?  (Read 6651 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: How to check if list a part of list?
« Reply #15 on: October 22, 2019, 05:25:40 PM »
Another a little bit slover…

Code: [Select]
(benchmark '(
(vl-some '(lambda (x) (equal x pt 1e-8)) lst)
(vl-member-if '(lambda (x) (equal x pt 1e-8)) Lst)
(vl-some '(lambda (x) (equal x pt 1e-8)) lst)
(vl-member-if '(lambda (x) (equal x pt 1e-8)) Lst)
))
elapsed milliseconds / relative speed for 1024 iteration(s):

    (VL-SOME (QUOTE (LAMBDA (X) (EQUAL X...).....1484 / 1.04 <fastest>
    (VL-SOME (QUOTE (LAMBDA (X) (EQUAL X...).....1500 / 1.03
    (VL-MEMBER-IF (QUOTE (LAMBDA (X) (EQ...).....1531 / 1.01
    (VL-MEMBER-IF (QUOTE (LAMBDA (X) (EQ...).....1547 / 1 <slowest>

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to check if list a part of list?
« Reply #16 on: October 22, 2019, 08:56:01 PM »
Diminishing returns, how do they work?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to check if list a part of list?
« Reply #17 on: October 22, 2019, 09:01:33 PM »
... like building a house on sand.

:nodding:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: How to check if list a part of list?
« Reply #18 on: October 23, 2019, 03:00:00 AM »
Diminishing returns, how do they work?
I hope I understood the question well...
with vl-member-if there is the advantage of having a return value with more information
Code: [Select]
((lambda (/ i)
   (setq i   '(0. 0. 0.)
         lst nil
         ) ;_ end of setq
   (repeat 8192 (setq lst (cons (setq i (mapcar (function +) i '(0.25 0.25 0.25))) lst)) => )
   (princ)
   ) ;_ end of lambda
)
Code: [Select]
(setq pt (nth    0 lst)) =>  (2048.0 2048.0 2048.0)
Elapsed milliseconds / relative speed for 32768 iteration(s):
    (VL-MEMBER-IF (QUOTE (LAMBDA (X) (EQ...).....1171 / 1 <fastest>
    (VL-SOME (QUOTE (LAMBDA (X) (EQUAL X...).....1172 / 1 <slowest>

(setq pt (nth   10 lst)) => (2045.5 2045.5 2045.5)
Elapsed milliseconds / relative speed for 32768 iteration(s):
    (VL-MEMBER-IF (QUOTE (LAMBDA (X) (EQ...).....1218 / 1 <fastest>
    (VL-SOME (QUOTE (LAMBDA (X) (EQUAL X...).....1219 / 1 <slowest>

(setq pt (nth   50 lst)) => (2035.5 2035.5 2035.5)
Elapsed milliseconds / relative speed for 32768 iteration(s):
    (VL-SOME (QUOTE (LAMBDA (X) (EQUAL X...).....1437 / 1 <fastest>
    (VL-MEMBER-IF (QUOTE (LAMBDA (X) (EQ...).....1438 / 1 <slowest>

(setq pt (nth  100 lst)) => (2023.0 2023.0 2023.0)
Elapsed milliseconds / relative speed for 32768 iteration(s):
    (VL-SOME (QUOTE (LAMBDA (X) (EQUAL X...).....1797 / 1 <fastest>
    (VL-MEMBER-IF (QUOTE (LAMBDA (X) (EQ...).....1797 / 1 <slowest>

(setq pt (nth  500 lst)) => (1923.0 1923.0 1923.0)
Elapsed milliseconds / relative speed for 8192 iteration(s):
    (VL-SOME (QUOTE (LAMBDA (X) (EQUAL X...).....1015 / 1.03 <fastest>
    (VL-MEMBER-IF (QUOTE (LAMBDA (X) (EQ...).....1047 / 1 <slowest>

(setq pt (nth 1000 lst)) => (1798.0 1798.0 1798.0)
Elapsed milliseconds / relative speed for 8192 iteration(s):
    (VL-SOME (QUOTE (LAMBDA (X) (EQUAL X...).....1781 / 1.02 <fastest>
    (VL-MEMBER-IF (QUOTE (LAMBDA (X) (EQ...).....1813 / 1 <slowest>

(setq pt (nth 2000 lst)) => (1548.0 1548.0 1548.0)
Elapsed milliseconds / relative speed for 4096 iteration(s):
    (VL-SOME (QUOTE (LAMBDA (X) (EQUAL X...).....1610 / 1.03 <fastest>
    (VL-MEMBER-IF (QUOTE (LAMBDA (X) (EQ...).....1656 / 1 <slowest>

(setq pt (nth 3000 lst)) => (1298.0 1298.0 1298.0)
Elapsed milliseconds / relative speed for 2048 iteration(s):
    (VL-SOME (QUOTE (LAMBDA (X) (EQUAL X...).....1156 / 1.04 <fastest>
    (VL-MEMBER-IF (QUOTE (LAMBDA (X) (EQ...).....1203 / 1 <slowest>

(setq pt (nth 4000 lst)) => (1048.0 1048.0 1048.0)
Elapsed milliseconds / relative speed for 2048 iteration(s):
    (VL-SOME (QUOTE (LAMBDA (X) (EQUAL X...).....1516 / 1.04 <fastest>
    (VL-MEMBER-IF (QUOTE (LAMBDA (X) (EQ...).....1578 / 1 <slowest>

(setq pt (nth 5000 lst)) => (798.0 798.0 798.0)
Elapsed milliseconds / relative speed for 2048 iteration(s):

    (VL-SOME (QUOTE (LAMBDA (X) (EQUAL X...).....1859 / 1.04 <fastest>
    (VL-MEMBER-IF (QUOTE (LAMBDA (X) (EQ...).....1937 / 1 <slowest>

(setq pt (nth 6000 lst)) => (548.0 548.0 548.0)
Elapsed milliseconds / relative speed for 1024 iteration(s):
    (VL-SOME (QUOTE (LAMBDA (X) (EQUAL X...).....1109 / 1.04 <fastest>
    (VL-MEMBER-IF (QUOTE (LAMBDA (X) (EQ...).....1156 / 1 <slowest>

(setq pt (nth 7000 lst)) => (298.0 298.0 298.0)
Elapsed milliseconds / relative speed for 1024 iteration(s):
    (VL-SOME (QUOTE (LAMBDA (X) (EQUAL X...).....1312 / 1.05 <fastest>
    (VL-MEMBER-IF (QUOTE (LAMBDA (X) (EQ...).....1375 / 1 <slowest>

(setq pt (last lst)) => (0.25 0.25 0.25)
Elapsed milliseconds / relative speed for 1024 iteration(s):
    (VL-SOME (QUOTE (LAMBDA (X) (EQUAL X...).....1516 / 1.04 <fastest>
    (VL-MEMBER-IF (QUOTE (LAMBDA (X) (EQ...).....1578 / 1 <slowest>