Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #413

Re: Function defined by a while loop

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!newsfeed.x-privat.org!diesel.cu.mi.it!not-for-mail
From Mauro <pippo@hotmail.com>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: Function defined by a while loop
Date Tue, 28 Jun 2011 11:56:13 +0200
Organization C.U. srl News Server
Lines 36
Message-ID <iuc8dd$ir1$1@tdi.cu.mi.it> (permalink)
References <b935110d-6f8d-4b0d-919c-3151effdf59f@28g2000yqu.googlegroups.com> <96s5qpFmfqU1@mid.dfncis.de>
NNTP-Posting-Host 147.162.219.242
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 8bit
X-Trace tdi.cu.mi.it 1309254893 19297 147.162.219.242 (28 Jun 2011 09:54:53 GMT)
X-Complaints-To abuse@diesel.cu.mi.it
NNTP-Posting-Date Tue, 28 Jun 2011 09:54:53 +0000 (UTC)
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; it; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11
In-Reply-To <96s5qpFmfqU1@mid.dfncis.de>
Xref x330-a1.tempe.blueboxinc.net comp.graphics.apps.gnuplot:413

Show key headers only | View raw


Il 27/06/2011 22:00, Hans-Bernhard Bröker ha scritto:
> On 27.06.2011 11:50, Antonio Lo Turco wrote:
>
>> Obviously I tried and it doesn't work!
>
> Of course it doesn't. while is a _command_, not an expression. You can't
> use it in the middle of an expression, like the one you use to define a
> function.
>
>> However I would like (and I'm not able) to implement such solution as
>> a user defined function.
>
> The only way there is recursion. But that will only work reasonably well
> for a _one_parameter_ loop. You loop over 'x' and 'i' simultaneously.
> That doesn't map cleanly to recursion over a single variable.
>
> Well, unless you make them the real and imaginary part of a complex
> number that is:
>
> iterate_f(x_i, x0, eps, maxiter) = \
> ((abs(real(x_i) - x0) < eps) || (imag(x_i) > maxiter)) \
> ? x_i \
> : iterate(f(real(x_i)) + (imag(x_i)+1)*{0,1}, x0, eps, maxiter)
>
> print iterate(x0,x0,eps,maxiter)

Thank you indeed!!!
Furthermore, it doesn't need while construct.
Nevertheless,I must congratulate all the Gnuplot development team for 
improving this unvaluable tool. The introduction of if, while and do for 
iterative constructs gives a further cut above to its practicality 
(maybe not for the functions ;-)).

Best regards

Mauro

Back to comp.graphics.apps.gnuplot | Previous | NextPrevious in thread | Find similar


Thread

Function defined by a while loop Antonio Lo Turco <antonio.lo.turco@gmail.com> - 2011-06-27 02:50 -0700
  Re: Function defined by a while loop James Waldby <not@valid.invalid> - 2011-06-27 16:21 +0000
    Re: Function defined by a while loop Mauro <pippo@hotmail.com> - 2011-06-28 11:48 +0200
  Re: Function defined by a while loop Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2011-06-27 22:00 +0200
    Re: Function defined by a while loop Mauro <pippo@hotmail.com> - 2011-06-28 11:56 +0200

csiph-web