Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*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 2000

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

Search the Archive

Re: Appending an element to a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23921] Re: Appending an element to a list
  • From: Brian Higgins <bghiggins at ucdavis.edu>
  • Date: Fri, 16 Jun 2000 00:57:01 -0400 (EDT)
  • References: <WIl15.112$lD2.68356@ralph.vnet.net> <8i9os0$2d4@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Felix,
 Perhaps this will do what you need:

myAppendFunc[oldList_, newList_ /; Length[newList] > 0] :=
  Append[oldList, newList]
myAppendFunc[oldList_, newList_ /; Length[newList] == 0] :=
oldList

And here is a test:

c1 = {{2, 2}, {3, 3}}
myAppendFunc[c1, {2, 5}]
{{2, 2}, {3, 3}, {2, 5}}
myAppendFunc[c1, {}]
{{2, 2}, {3, 3}}

Cheers,

Brian

In article <8i9os0$2d4 at smc.vnet.net>,
  Felix Farkas <farkas at icamail.epfl.ch> wrote:
> Hello,
>  i do have a problem, which is probably very easy,  but i couldn't
find
> a reasonable way to solve it. I would appreciate very much any
hint.
>
> I have a list of lists. My purpose is to append a new elements to
this
> list. These elements are generated by some function.
Sometimes the
> output of the function is an empty list meaning no element. In
this
> situation Append includes the new element in the list. i would
like to
> avoid this behaviour.
>
> ex:
>
> In[1]:=           d={}
> Out[1]=         {}
>
> In[2]:=           Append[{{2,2},{3,3}},d]
> Out[2]:=        {{2,2},{3,3},{}}
>
> Thanks in advance. Felix Farkas
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


  • Prev by Date: Re: Monte Carlo in Mathematica ?
  • Next by Date: Re: Integral evaluation bug?
  • Previous by thread: RE: Appending an element to a list
  • Next by thread: Problem with implementing the following functions