Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Simple Module Code

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49541] Re: [mg49510] Simple Module Code
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Fri, 23 Jul 2004 05:59:28 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

>-----Original Message-----
>From: Doug [mailto:umdougmm at hotmail.com]
To: mathgroup at smc.vnet.net
>Sent: Thursday, July 22, 2004 8:46 AM
>To: mathgroup at smc.vnet.net
>Subject: [mg49541] [mg49510] Simple Module Code
>
>
>Does anyone know why the following code would not work inside a module?
>list = AppendTo[list, data];
>
>here's the exact code
>splitData[data_, list_, i_] := Module[{},
>Print["In Split Data ", i];
>
>If[data[[i,1]]==1, list = AppendTo[list, data[[i, 2]]]];
>Print["Length of list is: ", Length[list]];
>]
>
>which is called by:
>Do[splitData[data, list, i], {i, 1, Length[data]}]
>
>It complains about to many recursions, yet on the command line alone,
>list = AppendTo[list, data];
>works just fine?
>
>Thanks
>Doug
>
>
>
>

There may be *lots* of reasons why your code might fail 
(and BTW, your example list = AppendTo[list, data] might fail as well).

A most obvious reason is that in your Module code "list" appears at the lhs, but this is the _evaluated_ second argument of splitData, which most often happens not to be something that can be assigned to. 

To give you a reasonable answer, you should supply (at least one, perhaps simplified) application case that doesn't work.

--
Hartmut


  • Prev by Date: Re: RE: simple problem with Map?!?
  • Next by Date: DisplayTogether, multiple ListPlots, compound paths, and Illustrator/EPS problems
  • Previous by thread: Re: Simple Module Code
  • Next by thread: Plotting 2D functions with discontinuities