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

0 Members and 1 Guest are viewing this topic.

robertocuba

  • Guest
Hello:

Iīm developing a following routine to remove elements from a list between identifiers "x" .... "x" of sub-list (recursive).

Problem:
List: ("a" 3 4 5 5 "b" 8 7 6 3 2 2 1 1 "c" 5 67 87 76 "d" 9 0 5 49 5 9)

The routine must be return:

List:  ("a" 3 4 5 "b" 8 7 6 3 2 1 "c" 5 67 87 76 "d" 9 0 5 49)

Thanks !

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 #1 on: June 08, 2009, 01:42:22 PM »
Post the code you've developed so far.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

uncoolperson

  • Guest
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #2 on: June 08, 2009, 02:49:50 PM »
from your example I'm having trouble understanding what you want to remove.

in three instances duplicated items have one removed
then there's the items at the end that are removed

robertocuba

  • Guest
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #3 on: June 08, 2009, 03:00:06 PM »
Yes, I want remove the similar elements, between "a" and "b", and between "b" and " and ...

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 #4 on: June 08, 2009, 03:01:45 PM »
It appears to me that alpha characters are delimiters, anything before, between or after are subgroups, and the OP's want is to have each subgroup sport unique members. I'm getting a strong impression these exercises are actually homework assignments, and as much as I enjoy challenges, I have no interest if they are indeed homework. Of course I'm open to hearing an alternative explanation and viewing the OP's attempts thus far.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

uncoolperson

  • Guest
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #5 on: June 08, 2009, 03:46:18 PM »
it was fun solving though.

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 #6 on: June 08, 2009, 03:53:23 PM »
Agreed.

Mine's a bit verbose at 14 lines.
« Last Edit: June 08, 2009, 04:02:25 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

uncoolperson

  • Guest
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #7 on: June 08, 2009, 04:14:13 PM »
3 recursives, not very streamlined... way too many lines that look similar and are begging to be condensed. it was fun to think through.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #8 on: June 08, 2009, 04:51:13 PM »
14 lines too (vlisp formated), only one recursive sub
Speaking English as a French Frog

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #9 on: June 08, 2009, 05:01:17 PM »
Ummm...*Se7en: scratches head* ...why recursive?

And if this is homework then; `recursive' describes the procedure not necessarily the type of process. So what kind of process? -i.e. you want a ``Recursive procedure using a ______ process which will remove the elements....''?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #10 on: June 08, 2009, 05:16:31 PM »
11 lines, but need to call (foo lst nil)
Speaking English as a French Frog

uncoolperson

  • Guest
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #11 on: June 08, 2009, 05:30:48 PM »
you know I've never understood counting lines in lisp.

I mean in theory mine could be 3 lines.


(sorry, just trying to make me feel better about myself)

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #12 on: June 08, 2009, 05:34:54 PM »
<snip>
I mean in theory mine could be 3 lines.
<snip>
In theory,  it could be one. *lol*
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

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 #13 on: June 08, 2009, 06:00:25 PM »
11 lines, but need to call (foo lst nil)

Bizarro world: same here but 12 lines, 15 with the wrapper. :D

1 line if I skip the superfluous carriage returns.  :-D
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

robertocuba

  • Guest
Re: remove elements from a list with identifier of sub-list (recursive)
« Reply #14 on: June 08, 2009, 06:17:13 PM »
The code?

Thanks !