MathGroup Archive 2007

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

Search the Archive

Re: neat way to program minimum of sum


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