Author Topic: remove elements from a list with identifier of sub-list (recursive)  (Read 11461 times)

0 Members and 1 Guest are viewing this topic.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2140
  • class keyThumper<T>:ILazy<T>
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #45 on: June 09, 2009, 05:53:51 PM »
well were you expecting anything else? ...try using foreach instead and you will really smoke us.

MP, quick question; I never quite understood what "relative speed for ... iteration(s):" meant? Is that the time per call?

Means that (NODOUPS BLAH) is 22.5 times faster than   (DOIT BLAH)

ie  1031:23203
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #46 on: June 09, 2009, 06:01:46 PM »
I'm pretty sure WHILE is faster than FOREACH.

In my test gile's was faster. :-o
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #47 on: June 09, 2009, 06:04:32 PM »
If non recursive functions are allowed, here's mine

Code: [Select]
(defun gile2 (lst / item tmp result)
  (while lst
    (if (numberp (setq item (car lst)))
      (if (not (vl-position item tmp))
(setq tmp (cons item tmp))
      )
      (setq result (append tmp result)
    tmp    (list item)
      )
    )
    (setq lst (cdr lst))
  )
  (reverse (append tmp result))
)
Speaking English as a French Frog

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #48 on: June 09, 2009, 06:16:04 PM »
Nice Gile.
My results.
Quote
   (GILE2 LST)............................1592 / 2.15 <fastest>
    (GILE LST).............................1632 / 2.09
    (NODOUPS LST)..........................1683 / 2.03
    (MP_FOO LST)...........................2504 / 1.36
    (REMOVE_DUPS_IN-BETWEEN-CHARS LST).....3415 / 1.00 <slowest>

Not sure why my test are different.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #49 on: June 09, 2009, 06:18:02 PM »
<Naive Question>:

Do you all have the same LISP to test the speed of these things?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #50 on: June 09, 2009, 06:19:28 PM »
Everyone except KB.  :-D
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

uncoolperson

  • Guest

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #52 on: June 09, 2009, 07:16:01 PM »
Means that (NODOUPS BLAH) is 22.5 times faster than   (DOIT BLAH)

ie  1031:23203
Ah, i see it. That makes total sense now that you put it that way...thanx!
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org


kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2140
  • class keyThumper<T>:ILazy<T>
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #54 on: June 09, 2009, 07:29:06 PM »
Everyone except KB.  :-D

Yep :)

I have mine calculating the  fastest as base 1 unit, and all athers with a higher relative index representing how much longer it takes to run..

ie if the fastest is 1 and the slowest is 12.6 you know it takes 12.6 times as long to run

but that's just me :)


Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #55 on: June 09, 2009, 09:20:29 PM »
That sounds more logical, is that posted anywhere KB?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2140
  • class keyThumper<T>:ILazy<T>
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #56 on: June 09, 2009, 09:50:25 PM »
That sounds more logical, is that posted anywhere KB?
Code: [Select]
                ;;=================================================================
                 ;;
                 ;;  Output:
                 ;;
                 ;;      Elapsed milliseconds / relative speed for 32768 iteration(s):
                 ;;
                 ;;    (+ 1 1.0).......1452 / 1.1152 <slowest>
                 ;;    (+ 1.0 1.0).....1412 / 1.0845
                 ;;    (+ 1 1).........1332 / 1.023
                 ;;    (1+ 1)..........1302 / 1 <fastest>
                 ;;
                 ;; Mods by KWB 2005 to display the smallest time with the smallest ratio
                 ;;
                 ;;=================================================================


I've also modified this .. which [you] may want to revert to the original
Code: [Select]
  (defun _main
         (statements / boundary iterations timings slowest fastest lsetlen rsetlen index count)
    (setq boundary 500 ; originally 1000 [kwb]
          iterations 1
    )
;; < ... big snip ...  >
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #57 on: June 09, 2009, 10:17:54 PM »
That sounds more logical

Doesn't to me. I think in terms of "Function A is x times faster than function B". Guess that makes me weird. :ugly:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

uncoolperson

  • Guest
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #58 on: June 09, 2009, 11:36:34 PM »
Guess that makes me weird. :ugly:

yeah... only that

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #59 on: June 10, 2009, 08:47:34 AM »
That sounds more logical

Doesn't to me. I think in terms of "Function A is x times faster than function B". Guess that makes me weird. :ugly:
Sorry, I didnt mean that statement as an insult.


*lol*
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org