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

MathGroup Archive 2009

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

Search the Archive

Re: mergeSort with ReplaceRepeated

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100871] Re: mergeSort with ReplaceRepeated
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Tue, 16 Jun 2009 21:54:59 -0400 (EDT)
  • References: <h0vtii$737$1@smc.vnet.net> <200906150121.VAA11576@smc.vnet.net>

Hi Luca,

My appologies if I have misjudged you. Indeed, the group regularly
gets asked questions by students that are copied straight from their
assignments, and the wording from your first post seemed to indicate
this was the case here as well.

Anyway, I still think you should become familiar with the basic stuff
before you try to go any deeper.

If you have Mathematica 6 or 7 you'll have a documentation centre
which is full of examples, each of which can be readily modified and
executed. If you are going to use functions like your merge, I'd
suggest at least reading the parts about function definitions.

Cheers -- Sjoerd


On Jun 15, 11:36 am, Luca Bedogni <bedogni.l... at gmail.com> wrote:
> Well, it is not really an homework. I'm trying to understand Mathematica,
> and now I want to learn the replacerepeated mechanism. Googling around, I
> found some exercises, and one is to make a mergesort function using
> replacerepeated, and that was my question.
>
> Thank you
> --
> Luca Bedogni
>
> 2009/6/15 Sjoerd C. de Vries <sjoerd.c.devr... at gmail.com>
>
> > Judging from your June 6 post, this is a homework assignment of yours.
> > I guess that given the code below you haven't learned enough of the
> > Mathematica language to come even close to solving it.
>
> > Since it is not the goal of this group to make your homework, I can
> > only advise you to learn the basics using the documentation included
> > with Mathematica before you endeavour in the more complicated stuff.
>
> > The code below doesn't work for one thing because it doesn't contain
> > an actual function definition. This is usually done using Set (=) or
> > SetDelayed (:=). Look them up in the documentation.
>
> > Cheers -- Sjoerd
>
> > On Jun 13, 12:04 pm, Luca Bedogni <bedogni.l... at gmail.com> wrote:
> > > Hi
> > >    I'm writing an implementation of mergesort using replacerepeat=
ed.
> > > This is actually the code:
> > > merge[{a1, arest___}, b : {b1, ___}] /; a1 >= b1 //. {merge[a1, are=
st, =
> > b1]
> > > :> merge[b1, a1, arest] };
> > > but it doesn't work, and I don't know why, because I'm really new to
> > > Mathematica.
>
> > > Any clue?
>
> > > Regards
> > > --
> > > Luca Bedogni



  • Prev by Date: Re: Problem of NUMERICAL constraints (Ndsolve) with Nminimize
  • Next by Date: Re: How to use R within Mathematica
  • Previous by thread: Re: Re: mergeSort with ReplaceRepeated
  • Next by thread: Re: Re: Re: mergeSort with ReplaceRepeated