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

MathGroup Archive 2009

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

Search the Archive

Re: Re: mergeSort with ReplaceRepeated

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100826] Re: [mg100820] Re: mergeSort with ReplaceRepeated
  • From: Luca Bedogni <bedogni.luca at gmail.com>
  • Date: Mon, 15 Jun 2009 05:36:54 -0400 (EDT)
  • References: <h0vtii$737$1@smc.vnet.net> <200906150121.VAA11576@smc.vnet.net>

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.devries 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 replacerepeated.
> > This is actually the code:
> > merge[{a1, arest___}, b : {b1, ___}] /; a1 >= b1 //. {merge[a1, arest, =
> 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: Extracting contour values from ContourPlot
  • Next by Date: FITS format and Mathematica 6
  • Previous by thread: Re: mergeSort with ReplaceRepeated
  • Next by thread: Re: mergeSort with ReplaceRepeated