MathGroup Archive 2009

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

Search the Archive

Re: Flatten alternative

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105487] Re: Flatten alternative
  • From: Norbert Marxer <marxer at mec.li>
  • Date: Sat, 5 Dec 2009 05:31:48 -0500 (EST)
  • References: <hfakvn$6re$1@smc.vnet.net>

On Dec 4, 10:32 am, Jezzybear <jezzybea... at hotmail.co.uk> wrote:
> I am trying to create a function myflat[list] to mimic the behavior of
> Mathematica's Flatten[]
> function.Example:
> In[1]:= myflat[{{{a}}, {b, c}, {d}}]
> Out[1]= {a, b, c, d}
> In[2]:= myflat[{{}, 1, {{2}}}]
> Out[2]= {1, 2}
> However in writing this function I want to use only  Mathematica's
> pattern matching features, the functions
> First[], Rest[], Prepend[], ListQ[]. I am trying to do this using some
> subfunctions like creating one called myjoin

Hello

You mean pattern matching like:

     myflat[x_] := {x //. List -> Sequence}

Best Regards
Norbert Marxer



  • Prev by Date: Foldlist with more than one list as argument
  • Next by Date: Re: Flatten alternative
  • Previous by thread: Re: Flatten alternative
  • Next by thread: Re: Flatten alternative