Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2009

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

Search the Archive

Re: simple question

  • To: mathgroup at
  • Subject: [mg99697] Re: simple question
  • From: Peter Pein <petsie at>
  • Date: Mon, 11 May 2009 06:26:18 -0400 (EDT)
  • References: <gu660n$9jh$>

Francisco Gutierrez schrieb:
> Dear Sirs:
> I have a function whose output is of the form {{a,b,c},{d,e,f},k}
> That is, a list of length 3, of which the first two parts are lists and the last part is a number
> Now, I want to iterate it, with the following termination criterion: stop if the first two parts of the output are identical in two successive runs.
> The intuitive (or naively intuitive if you want) way of attacking the problem, I think, is the following:
> NestWhile[f,startinglist,UnsameQ[{#[[1]],#[[2]]}&,2]
> But it does not work.
> What is the solution?
> Fg
Dear Francisco,

Well, {x,y} is unsame to almost every imaginable objects - especially from 
nothing -  but from {x,y}. What result do we expect, calling UnsameQ with one 
Look at the difference between:
In[1]:= UnsameQ[{1,1}]
Out[1]= True
OK, {1,1} is different from nothing.
In[2]:= UnsameQ[1,1]
Out[2]= False
Oh yeah! 1 is not different from 1

Additionally: count the opening an closing brackets!


  • Prev by Date: Re: numbered figures
  • Next by Date: Re: second simple problem
  • Previous by thread: Re: Re: simple Question
  • Next by thread: Re: simple question