Assuming the payments in arrears model (which is not what Bill asked for), if only the final balance is wanted:
(1+r)#. d NB.using print precision 8 1740.396 Adverb \ (prefix) applies its _monadic_ left verb to a progressively larger array of the single argument. With an equivalent adverb for a _dyadic_ left verb, we can still use #. (base) and get intermediate results: dyadprefix ┌─┬─┬──────────────────┐ │1│:│u \ y │ │ │ │: │ │ │ │> (<\x)u L:0 (<\y)│ └─┴─┴──────────────────┘ (1+r) ;dyadprefix d ┌────────────────────────┬──────────────┐ │1.05 │1000 │ ├────────────────────────┼──────────────┤ │1.05 1.04 │1000 0 │ ├────────────────────────┼──────────────┤ │1.05 1.04 1.06 │1000 0 0 │ ├────────────────────────┼──────────────┤ │1.05 1.04 1.06 1.05 │1000 0 0 500 │ ├────────────────────────┼──────────────┤ │1.05 1.04 1.06 1.05 1.05│1000 0 0 500 0│ └────────────────────────┴──────────────┘ (1+r) #.dyadprefix d 1000 1040 1102.4 1657.52 1740.396 For a good exposure on base: Actuarial and financial calculations with base value David Michelson, International Conference Proceedings APL'89, p.273-277 APL QuoteQuad 19-4 ~ Gilles ---------- Original Message ----------- From: "R.E. Boss" <[email protected]> To: "'Programming forum'" <[email protected]> Sent: Mon, 20 Jul 2009 14:24:51 +0200 Subject: Re: [Jprogramming] Accumulation, interest, and simulation > In all cases I prefer elegance. > And after that simplicity. > > R.E Boss > > > -----Oorspronkelijk bericht----- > > Van: [email protected] [mailto:programming- > > [email protected]] Namens Roger Hui > > Verzonden: maandag 20 juli 2009 1:32 > > Aan: Programming forum > > Onderwerp: Re: [Jprogramming] Accumulation, interest, and simulation > > > > In all but the simplest cases, I prefer forks over hooks. > > > > > > > > ----- Original Message ----- > > From: "R.E. Boss" <[email protected]> > > Date: Sunday, July 19, 2009 12:38 > > Subject: Re: [Jprogramming] Accumulation, interest, and simulation > > To: 'Programming forum' <[email protected]> > > > > > acc1=: (] * +/\@:%) */\ > > > d acc1 1+r > > > 1000 1040 1102.4 1657.52 1740.396 > > > > > > > > > R.E. Boss > > > > > > > > > > -----Oorspronkelijk bericht----- > > > > Van: [email protected] [mailto:programming- > > > > [email protected]] Namens Roger Hui > > > > Verzonden: zaterdag 18 juli 2009 18:43 > > > > Aan: Programming forum > > > > Onderwerp: Re: [Jprogramming] Accumulation, interest, and simulation > > > > > > > > Found it. Now the question is whether it solves > > > > the same problem. > > > > > > > > John Gaboury, Letter to the Editor, APL Quote-Quad, > > > > Volume 7, Number 4, Winter 1977. > > > > > > > > acc=: [ (] * +/\@:%) */\...@] > > > > > > > > r=. 0.05 0.04 0.06 0.05 0.05 NB. > > > interest rates > > > > d=. 1000 0 0 500 > > > 0 NB. deposits > > > > d acc 1+r > > > > 1000 1040 1102.4 1657.52 1740.4 > > > > > > > > > > > > > > > > ----- Original Message ----- > > > > From: Roger Hui <[email protected]> > > > > Date: Saturday, July 18, 2009 9:19 > > > > Subject: Re: [Jprogramming] Accumulation, interest, and simulation > > > > To: Programming forum <[email protected]> > > > > > > > > > There was (I think) a very neat solution APL published > > > > > in the Quote-Quad in the late 1970s - early 1980s. > > > > > It was a very short one-liner involving */\ and +/\ . > > > > > I'll see if I can find it or reproduce it. > > > > > > > > > > Perhaps Joey Tuttle (the keeper of all things) would > > > > > have a copy of it. I am pretty sure it would be in > > > > > one of the IPSA utility workspaces, such as 880 sauce. > > > > > The function would be called "accum" or some such. > > > > > > > > > > > > > > > > > > > > ----- Original Message ----- > > > > > From: Bill Harris <[email protected]> > > > > > Date: Saturday, July 18, 2009 8:20 > > > > > Subject: Re: [Jprogramming] Accumulation, interest, and simulation > > > > > To: Programming forum <[email protected]> > > > > > > > > > > > Thanks, all. I figured \. came into it somehow, but I > > > > > > didn't get from > > > > > > there to the end. I'll study your solutions later today. > > > > > > > > > > > > Bill > > > > > > > > > > > > PS: Thanks for not being misled by my typo in the original > > > Aprime> > > example, which didn't include the second deposit in the > > > > > rolling sum. > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ------- End of Original Message ------- ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
