Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > recursion

Reply
Thread Tools

recursion

 
 
oliver
Guest
Posts: n/a
 
      08-16-2007
I'd like to code something recursively - it's not going to be in C
(VBA actually) but I hope this is the best place to ask.
I have a Bill of Materials structured like this:

row description
1 main assembly
2 .subassembly (of 1)
3 ..subassembly (of 2)
4 .subassembly (of 1)
5 ..subassembly (of 4)
6 ...subassembly (of 5)
7 .subassembly (of 1)

and I need to turn this into a table that looks like this
row parent
1 -
2 1
3 2
4 1
5 4
6 5
7 1

The (of 1, of 2) in the descritpions don't actually exist in the data,
the dots preceeding the description tell you that.

Ok so please help - I've been chipping away at this for hours and it's
so long since I did my degree I've gone a bit dopey and can't see the
wood from the trees. I "KNOW" the most elegant way to handle this is
recursively I just can't figure out how today.

Thanks very much - really appreciate your input
Olly

 
Reply With Quote
 
 
 
 
Robert Gamble
Guest
Posts: n/a
 
      08-16-2007
On Aug 16, 12:00 pm, oliver <(E-Mail Removed)> wrote:
> I'd like to code something recursively - it's not going to be in C
> (VBA actually) but I hope this is the best place to ask.


[snip]

I don't know what makes you think that a C group is the best place to
ask questions about how to program a VBA app, I would suggest starting
with a group that has "vba" in its name. When you do it will also
probably be helpful to include the code that you have come up with so
far.

Robert Gamble

 
Reply With Quote
 
 
 
 
Flash Gordon
Guest
Posts: n/a
 
      08-16-2007
oliver wrote, On 16/08/07 17:00:
> I'd like to code something recursively - it's not going to be in C
> (VBA actually) but I hope this is the best place to ask.


<snip>

I seriously cannot think why you thought this would be a good place to
ask when you are explicitly not using C. I'm sure you will find groups
in the microsoft hierarchy for VBA, or for general algorithms work there
is comp.programming.
--
Flash Gordon
 
Reply With Quote
 
Jens Thoms Toerring
Guest
Posts: n/a
 
      08-16-2007
oliver <(E-Mail Removed)> wrote:
> I'd like to code something recursively - it's not going to be in C
> (VBA actually) but I hope this is the best place to ask.
> I have a Bill of Materials structured like this:


> row description
> 1 main assembly
> 2 .subassembly (of 1)
> 3 ..subassembly (of 2)
> 4 .subassembly (of 1)
> 5 ..subassembly (of 4)
> 6 ...subassembly (of 5)
> 7 .subassembly (of 1)


> and I need to turn this into a table that looks like this
> row parent
> 1 -
> 2 1
> 3 2
> 4 1
> 5 4
> 6 5
> 7 1


> The (of 1, of 2) in the descritpions don't actually exist in the data,
> the dots preceeding the description tell you that.


> Ok so please help - I've been chipping away at this for hours and it's
> so long since I did my degree I've gone a bit dopey and can't see the
> wood from the trees. I "KNOW" the most elegant way to handle this is
> recursively I just can't figure out how today.


Since this is more a question about an algorithm and not about C
(which you don't even want to use) I would recommend that you ask
in e.g. comp.programming. But anyway, this looks like a nice ex-
ample where one could employ a stack:

a) read in a line
b) If the number of dots is smaller or equal to the depth
of the stack pop elements from the stack until the depth
of the stack is one less than the number of dots.
c) Print out the number of the line and the top-most number
on the stack (or '-' if the stack is empty). Push the line
number onto the stack.
d) goto a)
Regards, Jens
--
\ Jens Thoms Toerring ___ http://www.velocityreviews.com/forums/(E-Mail Removed)
\__________________________ http://toerring.de
 
Reply With Quote
 
oliver
Guest
Posts: n/a
 
      08-16-2007
On 16 Aug, 17:56, Flash Gordon <(E-Mail Removed)> wrote:
> oliver wrote, On 16/08/07 17:00:
>
> > I'd like to code something recursively - it's not going to be in C
> > (VBA actually) but I hope this is the best place to ask.

>
> <snip>
>
> I seriously cannot think why you thought this would be a good place to
> ask when you are explicitly not using C. I'm sure you will find groups
> in the microsoft hierarchy for VBA, or for general algorithms work there
> is comp.programming.
> --
> Flash Gordon


Thanks for your unhelpful responses - what a waste of your time and
mine.
I posted on a C group because I used this board many years ago when I
was heavily involved in C programming and found the people helpful and
knowledgable.
I have no code because I can't get my head round the recursive side of
it, a solution I imagine will only be 10 or so lines long.
The language I implement this in, bar possibly the need for it to be
procedural, is absoloutely irrelevant!!!
I can simply port any C code to VBA. C is my language of choice and
an answer in C will be easiest for me to read.

I do take your point on board that a more generic .programming group
my help and will post there too.

 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      08-16-2007
oliver wrote, On 16/08/07 18:18:
> On 16 Aug, 17:56, Flash Gordon <(E-Mail Removed)> wrote:
>> oliver wrote, On 16/08/07 17:00:
>>
>>> I'd like to code something recursively - it's not going to be in C
>>> (VBA actually) but I hope this is the best place to ask.

>> <snip>
>>
>> I seriously cannot think why you thought this would be a good place to
>> ask when you are explicitly not using C. I'm sure you will find groups
>> in the microsoft hierarchy for VBA, or for general algorithms work there
>> is comp.programming.
>> --
>> Flash Gordon

>
> Thanks for your unhelpful responses - what a waste of your time and
> mine.


You chose to waste every bodies time by posting to what was obviously
the wrong group.

> I posted on a C group because I used this board many years ago when I


Then how come you don't know that this is not a board but a news group
and don't know to snip peoples signatures?

> was heavily involved in C programming and found the people helpful and


<snip>

> I do take your point on board that a more generic .programming group
> my help and will post there too.


So my post did not waste your time since it pointed you to a more
appropriate group.

Now we are don't to just you wasting peoples time.
--
Flash Gordon
 
Reply With Quote
 
oliver
Guest
Posts: n/a
 
      08-16-2007
On 16 Aug, 19:19, Flash Gordon <(E-Mail Removed)> wrote:
> oliver wrote, On 16/08/07 18:18:
>
>
>
> > On 16 Aug, 17:56, Flash Gordon <(E-Mail Removed)> wrote:
> >> oliver wrote, On 16/08/07 17:00:

>
> >>> I'd like to code something recursively - it's not going to be in C
> >>> (VBA actually) but I hope this is the best place to ask.
> >> <snip>

>
> >> I seriously cannot think why you thought this would be a good place to
> >> ask when you are explicitly not using C. I'm sure you will find groups
> >> in the microsoft hierarchy for VBA, or for general algorithms work there
> >> is comp.programming.
> >> --
> >> Flash Gordon

>
> > Thanks for your unhelpful responses - what a waste of your time and
> > mine.

>
> You chose to waste every bodies time by posting to what was obviously
> the wrong group.
>
> > I posted on a C group because I used this board many years ago when I

>
> Then how come you don't know that this is not a board but a news group
> and don't know to snip peoples signatures?
>
> > was heavily involved in C programming and found the people helpful and

>
> <snip>
>
> > I do take your point on board that a more generic .programming group
> > my help and will post there too.

>
> So my post did not waste your time since it pointed you to a more
> appropriate group.
>
> Now we are don't to just you wasting peoples time.
> --
> Flash Gordon


Hehe, that's more like it - a bit of bite - although it's not helping
me with my code prob. Thanks for the stack pointer - anyone got other
ideas?

Soooooo Mr Flash... I won't comment on your use of English on the
assumption it's not your first language. I have no idea what you mean
by 'snip signatures'...if you had any tradition and age behind you
then you'd appreciate calling this a board is hardly a serious faux
pas.

Here is appropriate in terms of I am certain there are people that
read this that knowledgeable enough to cut a little code to get me
started....maybe you are ----- who knows

 
Reply With Quote
 
user923005
Guest
Posts: n/a
 
      08-16-2007
On Aug 16, 9:00 am, oliver <(E-Mail Removed)> wrote:
> I'd like to code something recursively - it's not going to be in C
> (VBA actually) but I hope this is the best place to ask.
> I have a Bill of Materials structured like this:
>
> row description
> 1 main assembly
> 2 .subassembly (of 1)
> 3 ..subassembly (of 2)
> 4 .subassembly (of 1)
> 5 ..subassembly (of 4)
> 6 ...subassembly (of 5)
> 7 .subassembly (of 1)
>
> and I need to turn this into a table that looks like this
> row parent
> 1 -
> 2 1
> 3 2
> 4 1
> 5 4
> 6 5
> 7 1
>
> The (of 1, of 2) in the descritpions don't actually exist in the data,
> the dots preceeding the description tell you that.
>
> Ok so please help - I've been chipping away at this for hours and it's
> so long since I did my degree I've gone a bit dopey and can't see the
> wood from the trees. I "KNOW" the most elegant way to handle this is
> recursively I just can't figure out how today.
>
> Thanks very much - really appreciate your input


In C, structs that contain structs is the simple, obvious answer.
In SQL, it is tables with child tables.
Your question is better posed in news:comp.programming
I am guessing that a web search will turn up a BOM program in any
language that you like.

 
Reply With Quote
 
Al Balmer
Guest
Posts: n/a
 
      08-16-2007
On Thu, 16 Aug 2007 10:18:18 -0700, oliver <(E-Mail Removed)>
wrote:

>On 16 Aug, 17:56, Flash Gordon <(E-Mail Removed)> wrote:
>> oliver wrote, On 16/08/07 17:00:
>>
>> > I'd like to code something recursively - it's not going to be in C
>> > (VBA actually) but I hope this is the best place to ask.

>>
>> <snip>
>>
>> I seriously cannot think why you thought this would be a good place to
>> ask when you are explicitly not using C. I'm sure you will find groups
>> in the microsoft hierarchy for VBA, or for general algorithms work there
>> is comp.programming.
>> --
>> Flash Gordon

>
>Thanks for your unhelpful responses - what a waste of your time and
>mine.


Yep, that's what we're telling you. Your question has to do with
algorithms, not the C language. Two of the three replies advised you
to go to comp.programming. Why were they not helpful responses?

"I'm sorry, but this is Rochester, NY. The Mayo Clinic is in
Rochester, MN." Happens several times a year. Is that an unhelpful
response?

--
Al Balmer
Sun City, AZ
 
Reply With Quote
 
Al Balmer
Guest
Posts: n/a
 
      08-16-2007
On Thu, 16 Aug 2007 11:36:50 -0700, oliver <(E-Mail Removed)>
wrote:

>Here is appropriate in terms of I am certain there are people that
>read this that knowledgeable enough to cut a little code to get me
>started....maybe you are ----- who knows


Of course there are, but no one here is likely to do it for you.
That's not why we're here. If you want to try to write a program, in
C, and have problems, come on back. You'll get help from the best.

Perhaps you really need alt.sources.wanted.

Some other information: This isn't a bulletin board, and it's not
Google. Using the Google interface, you've found your way to a Usenet
newsgroup. "Signatures", or "sig blocks" are the text that you see
following the signature separator, which is two dashes and a space, on
a line by itself. You'll see one below. Traditionally, newsgroups are
accessed using a newsreader program, and proper newsreader programs
strip signature blocks on replies.

--
Al Balmer
Sun City, AZ
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
va_arg... recursion: changing arguments and the using recursion jononanon@googlemail.com C Programming 8 04-26-2012 08:37 PM
DNS recursion question while studying for 70-293 Kevin Porter MCSE 1 03-18-2006 05:56 AM
DNS recursion question while studying for 70-293 Kevin Porter Microsoft Certification 0 03-16-2006 11:10 PM
recursion with perl B McInnes Perl 4 11-04-2003 06:08 AM
Output buffering problems during recursion Tim Mohler Perl 1 09-16-2003 12:35 AM



Advertisments