Author Topic: Bicursion ...  (Read 18426 times)

0 Members and 1 Guest are viewing this topic.

uncoolperson

  • Guest
Re: Bicursion ...
« Reply #30 on: November 07, 2005, 11:10:18 PM »
I already knew it was broken... ("("(5 4 3 ) nil ")") is a real good time.

it was just humorous

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Bicursion ...
« Reply #31 on: November 07, 2005, 11:42:39 PM »
I already knew it was broken... ("("(5 4 3 ) nil ")") is a real good time.

it was just humorous

FLAME ON:
That type of post, particularly a supposed code solution, is not worth the bandwidth it takes to send it.
It's illogical and poorly reasoned. The rest of the world agrees with me.
FLAME OFF:
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

uncoolperson

  • Guest
Re: Bicursion ...
« Reply #32 on: November 08, 2005, 11:11:14 AM »
FLAME ON:

now where'd i put that fire extiguisher.... :roll:

hunterxyz

  • Guest
Re: Bicursion ...
« Reply #33 on: September 15, 2007, 12:25:25 AM »

Asked wants can let the result with what method equate to this ?
(setq lst '("A" ("B1" "B2" "B3" "B4" "B5") "C" "D" "E"))
=> (("A")
    (nil "B1")
    (nil "B2")
    (nil "B3")
    (nil "B4")
    ("C")
    ("D")
    ("E")
    )

(setq lst '(10 (20.1 20.2 20.3 20.4 20.5) 30 40 50))
=> ((10)
    (nil 20.1)
    (nil 20.2)
    (nil 20.3)
    (nil 20.4)
    (30)
    (40)
    (50)
    )

(setq lst '(10 (20 21 (22.1 22.2 (22.30 22.31 22.32) 22.4) 23 24) 30 (40 41 42) 50))
=> ((10)
    (nil 20)
    (nil 21)
    (nil nil 22.1)
    (nil nil 22.2)
    (nil nil nil 22.3)
    (nil nil nil 22.31)
    (nil nil nil 22.32)
    (nil nil 22.4)
    (nil 23)
    (nil 24)
    (30)
    (nil 40)
    (nil 41)
    (nil 42)
    (50)
    )

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Bicursion ...
« Reply #34 on: September 15, 2007, 11:33:22 AM »
I'm not sure what you're asking, but if you use the final function I
penned from this discussion and use it to process the three samples
you provided --

Code: [Select]
(   (lambda ( / flatten )

        (defun flatten ( lst / f1 f2 )
            (defun f1 ( lst )
                (apply 'append
                    (mapcar 'f2 lst)
                )
            )
            (defun f2 ( x / a )
                (if x
                    (if (listp x)
                        (if (listp (setq a (car x)))
                            (append (f1 a) (f1 (cdr x)))
                            (cons a (f1 (cdr x)))
                        )
                        (list x)
                    )
                   '(nil)
                )
            )
            (f1 lst)
        )

        (mapcar 'print

            (mapcar 'flatten

               '(
               
                    ("A" ("B1" "B2" "B3" "B4" "B5") "C" "D" "E")
                   
                    (10 (20.1 20.2 20.3 20.4 20.5) 30 40 50)
                   
                    (10 (20 21 (22.1 22.2 (22.30 22.31 22.32) 22.4) 23 24) 30 (40 41 42) 50)
               
                )

            )

        )
       
        (princ)

    )

)

It outputs this --

Code: [Select]
("A" "B1" "B2" "B3" "B4" "B5" "C" "D" "E")
(10 20.1 20.2 20.3 20.4 20.5 30 40 50)
(10 20 21 22.1 22.2 22.3 22.31 22.32 22.4 23 24 30 40 41 42 50)

Which in my mind faithfully honors the original intent of the function.

Hope that helps / clarifies.

Cheers and welcome to the swamp.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

hunterxyz

  • Guest
Re: Bicursion ...
« Reply #35 on: September 15, 2007, 09:29:36 PM »
Thank you the suggestion

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Bicursion ...
« Reply #36 on: September 16, 2007, 11:53:18 AM »
You're very welcome.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst