Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: <Null> while building lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg112211] Re: <Null> while building lists
  • From: jeremy duncan <jeremydcn at yahoo.com>
  • Date: Sun, 5 Sep 2010 05:26:12 -0400 (EDT)

maxima[f_] :==
 Block[{old == f[[1]], m == {}},
  For[i == 2, i < Length[f]/2, i++,
     If[f[[i]] > old && f[[i + 1]] < f[[i]], AppendTo[m, {i, f[[i]]}]];
     old == f[[i]]] m;]

I appended ; after final m. Maybe that is it?

Jeremy

--- On Sat, 4/9/10, Andy <andyr at wolfram.com> wrote:

> From: Andy <andyr at wolfram.com>
> Subject: [mg112205] Re: <Null> while building lists
> To: mathgroup at smc.vnet.net
> Received: Saturday, 4 September, 2010, 6:02 PM
>   On 9/3/2010 5:09 AM,
> Alessandro wrote:
> > Hi group,
> > I'm sure I'll bang me on my head as soon as I will
> Press<Post
> > Message>,
> > but it's since yesterday that I'm struggling with
> this...
> >
> > I fast defined this awkward function, to collect the
> {index,value} of
> > the maxima of a list of reals (a Fourier transform):
> >
> > maxima[f_] :== Block[{old == f[[1]], m == {}},
> >    For[i == 2, i<  Length[f]/2, i++,
> >      If[f[[i]]> 
> old&&  f[[i + 1]]<  f[[i]],
> >       AppendTo[m, {i,
> f[[i]]}]];
> >      old == f[[i]]
> >      ]
> >     m
> >    ]
> >
> > Problem is, what I get is e.g. this:
> >
> >> maxima[f]
> >> {{14 Null, 10.8853 Null}, {21 Null, 3.34261 Null},
> {28 Null, 1.47219 Null}}
> > I'm sure I do not have spaces anywhere (it happened
> something similar
> > due to this error, time ago),
> > so what's wrong?
> >
> > thanks for any help...
> >
> >
> > alessandro
> >
> >
> >
> >
> Missing a semicolon so Mathematica is seeing For[...] * m
> and For
> returns Null.
>
> maxima[f_] :==
>   Block[{old == f[[1]], m == {}},
>    For[i == 2, i < Length[f]/2, i++,
>     If[f[[i]] > old && f[[i + 1]] <
> f[[i]], AppendTo[m, {i, f[[i]]}]];
>     old == f[[i]]]; m]
>
> -Andy
>
>


     


  • Prev by Date: Re: Time Series Data in Quarters
  • Next by Date: Re: NDSolve -- n-body indexing ([[]]) problem
  • Previous by thread: Re: <Null> while building lists
  • Next by thread: Re: <Null> while building lists