MathGroup Archive 2007

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

Search the Archive

Re: neat way to program minimum of sum

  • To: mathgroup at smc.vnet.net
  • Subject: [mg75178] Re: neat way to program minimum of sum
  • From: CoolGenie <CGenie at gmail.com>
  • Date: Thu, 19 Apr 2007 04:36:39 -0400 (EDT)
  • References: <f01360$889$1@smc.vnet.net>

I like the answer I got from Daniel Lichtblau:

f[t_] := First[
  NestWhile[{#[[1]] + 1, #[[2]] + x[#[[1]]]} &,
 {1,0}, #[[2]]<t &]] - 1

I didn't check it but it's something that was going around my mind --
the iterator should be kept around somewhere and I like the idea to
keep it in a 2-element list together with the sum. This is truly
functional and I'm satisfied with it.

Thank you Daniel!

P. Kaminski



  • Prev by Date: Re: Re : Re: Interpolation
  • Next by Date: equation solving
  • Previous by thread: Re: neat way to program minimum of sum
  • Next by thread: Re: neat way to program minimum of sum