MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: While or not to While that is the question :)

  • To: mathgroup at
  • Subject: [mg46844] Re: While or not to While that is the question :)
  • From: "Hans Michel" <hansjm at>
  • Date: Wed, 10 Mar 2004 04:57:42 -0500 (EST)
  • References: <c2lpt2$9eb$>
  • Reply-to: "Hans Michel" <hansjm at>
  • Sender: owner-wri-mathgroup at


This feels like a word problem. So I am going to skip trying to solve it.

But if you are doing DNA work then go to this site

Many examples and most to do with DNA.


"János" <janos.lobb at> wrote in message
news:c2lpt2$9eb$1 at
> Hi,
> Inside a While loop I slide on a nested list like
> {a,{g,c},{t,a},c,g,a,{g,c},{a,t},c,,g,a,t,t}.  Let's say I start after
> {t,a} and {a,t} parallel - positions 4 and 9, that is element c and c.
> If I find a single element then I pair it with its corresponding DNA
> complement, a->t, t->a, c->g, g->c and replace the element with a
> sublist of the element and its complement.  So, after the first step my
> list will look like
> {a,{g,c},{t,a},{c,g},g,a,{g,c},{a,t},{c,g},g,a,t,t}.  If I find a
> double, like the {g,c} on position 7, then first I create a triplet
> from it {g,c,c} - the original c in the double is now on the third
> position inside the triplet -, and then after some housekeeping I take
> the third element of the triplet off and put it into another bucket, so
> the triplet becomes a double again and in the While I slide happily
> further right on the nested list.   In the above example I would hit
> {g,c} after 4 steps.  If I run the While, let say for 5 or more steps,
> it errors out complaining that I want to select some parts of the empty
> {} list.  If I ran it for 4 steps and then I manually execute ALL the
> statements inside the While for step 5, I do not see any complains and
> I can go up to as many steps manually, by increasing the loop variable,
> as my heart desires.
> As being a newbie I have not learned yet to use Modules or Blocks , - I
> am still just at page 320 in the book - so all my variables are
> globals.
> So my first question is why I am getting different results if I execute
> the while programatically, for 5 steps, compared to executing it for 4
> steps and do the 5th step manually?  I am using 5.0.1 on OS X.
> The first error message I get is this:
> \!\(\*
>    RowBox[{\(ReplacePart::"partw"\), \(\(:\)\(\ \)\), "\<\"Part
> \\!\\({1, 2}\\)
>       of \\!\\({}\\) does not
>        exist. \\!\\(\\*ButtonBox[\\\"More.\\\", \
> ButtonStyle->\\\"RefGuideLinkText\\\", ButtonFrame->None, \
> ButtonData:>\\\"General::partw\\\"]\\)\"\>"}]\)
> So, my second question is how to use Trace to determine where in the
> code do I get the first  "partw" ?  I use ReplacePart in 4 places
> inside the While, but at manual execution none of them complain.
> I am sure my code is far from perfect, but still it should give the
> same result on both cases.
> János
> -------------------------------------------------
> clear perl code is better than unclear awk code; but NOTHING comes
> close to unclear perl code

  • Prev by Date: Re: append to a file
  • Next by Date: Re: bessel function with complex order
  • Previous by thread: While or not to While that is the question :)
  • Next by thread: Re: While or not to While that is the question :)