<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Loan Amortization</title>
	<atom:link href="http://programmingpraxis.com/2009/05/12/loan-amortization/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmingpraxis.com/2009/05/12/loan-amortization/</link>
	<description>A collection of etudes, updated weekly, for the education and enjoyment of the savvy programmer</description>
	<lastBuildDate>Mon, 28 May 2012 03:30:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Kathryn Bewig</title>
		<link>http://programmingpraxis.com/2009/05/12/loan-amortization/#comment-130</link>
		<dc:creator><![CDATA[Kathryn Bewig]]></dc:creator>
		<pubDate>Sun, 24 May 2009 13:19:48 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=611#comment-130</guid>
		<description><![CDATA[This is my favorite posting yet, Dad. :)]]></description>
		<content:encoded><![CDATA[<p>This is my favorite posting yet, Dad. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: grettke</title>
		<link>http://programmingpraxis.com/2009/05/12/loan-amortization/#comment-109</link>
		<dc:creator><![CDATA[grettke]]></dc:creator>
		<pubDate>Fri, 15 May 2009 20:14:12 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=611#comment-109</guid>
		<description><![CDATA[A Solution in PLT Scheme.

This is the first Scheme program I had ever wrote; and its present form is the result of many kind folks helping me out :)

&lt;pre&gt;
#lang scheme

(define mamort
 (lambda (bal pcnt pay)
   (format &quot;Payment #,Payment Amount,Interest Paid,Principle
Paid,Balance,Total Interest~%&quot;)
   (amort bal pcnt pay 12)))

(define amort
 (lambda (bal pcnt pay freq)
   (let loop ((bal bal) (tot-int 0) (pmt 1))
     (let* ((int (* pcnt bal (/ freq)))
            (prin (min (- pay int) bal))
            (new-bal (- bal prin))
            (new-int (+ int tot-int))
            (done (&lt; (+ int prin) pay)))
       (if done
           (printf &quot;~s,~s,~s,~s,~s,~s~n&quot;
                   pmt (+ int prin) int prin new-bal new-int)
           (begin
             (printf &quot;~s,~s,~s,~s,~s,~s~n&quot;
                     pmt pay int prin new-bal new-int)
             (loop new-bal new-int (+ 1 pmt))))))))

(mamort 10000 .12 350)
&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>A Solution in PLT Scheme.</p>
<p>This is the first Scheme program I had ever wrote; and its present form is the result of many kind folks helping me out :)</p>
<pre>
#lang scheme

(define mamort
 (lambda (bal pcnt pay)
   (format "Payment #,Payment Amount,Interest Paid,Principle
Paid,Balance,Total Interest~%")
   (amort bal pcnt pay 12)))

(define amort
 (lambda (bal pcnt pay freq)
   (let loop ((bal bal) (tot-int 0) (pmt 1))
     (let* ((int (* pcnt bal (/ freq)))
            (prin (min (- pay int) bal))
            (new-bal (- bal prin))
            (new-int (+ int tot-int))
            (done (&lt; (+ int prin) pay)))
       (if done
           (printf "~s,~s,~s,~s,~s,~s~n"
                   pmt (+ int prin) int prin new-bal new-int)
           (begin
             (printf "~s,~s,~s,~s,~s,~s~n"
                     pmt pay int prin new-bal new-int)
             (loop new-bal new-int (+ 1 pmt))))))))

(mamort 10000 .12 350)
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Remco Niemeijer</title>
		<link>http://programmingpraxis.com/2009/05/12/loan-amortization/#comment-105</link>
		<dc:creator><![CDATA[Remco Niemeijer]]></dc:creator>
		<pubDate>Tue, 12 May 2009 12:16:55 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=611#comment-105</guid>
		<description><![CDATA[My Haskell solution (see http://bonsaicode.wordpress.com/2009/05/12/programming-praxis-loan-amortization/ for a version with comments):

[sourcecode lang=&#039;css&#039;]
import Text.Printf

amortize :: Float -&gt; Float -&gt; Int -&gt; [(Int, Float, Float, Float)]
amortize _ _ 0 = []
amortize b r l = (l - 1, prn, int, b&#039;) : amortize b&#039; r (l - 1)
                 where int = b * r
                       prn = int / (1 - (1 + r) ^^ (-l)) - int
                       b&#039; = b - prn

amortization :: Float -&gt; Float -&gt; Int -&gt; IO ()
amortization b r l = do
    putStrLn &quot;Left Principal Interest   Balance&quot;
    mapM_ table $ (l, 0, 0, b) : amortize b (r / 12 / 100) l
    where table (m, p, i, t) = printf &quot;%4d %9.2f %8.2f %9.2f\n&quot; m p i t

main :: IO ()
main = amortization 10000 7 36
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>My Haskell solution (see <a href="http://bonsaicode.wordpress.com/2009/05/12/programming-praxis-loan-amortization/" rel="nofollow">http://bonsaicode.wordpress.com/2009/05/12/programming-praxis-loan-amortization/</a> for a version with comments):</p>
<pre class="brush: css;">
import Text.Printf

amortize :: Float -&gt; Float -&gt; Int -&gt; [(Int, Float, Float, Float)]
amortize _ _ 0 = []
amortize b r l = (l - 1, prn, int, b') : amortize b' r (l - 1)
                 where int = b * r
                       prn = int / (1 - (1 + r) ^^ (-l)) - int
                       b' = b - prn

amortization :: Float -&gt; Float -&gt; Int -&gt; IO ()
amortization b r l = do
    putStrLn &quot;Left Principal Interest   Balance&quot;
    mapM_ table $ (l, 0, 0, b) : amortize b (r / 12 / 100) l
    where table (m, p, i, t) = printf &quot;%4d %9.2f %8.2f %9.2f\n&quot; m p i t

main :: IO ()
main = amortization 10000 7 36
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Programming Praxis &#8211; Loan Amortization &#171; Bonsai Code</title>
		<link>http://programmingpraxis.com/2009/05/12/loan-amortization/#comment-104</link>
		<dc:creator><![CDATA[Programming Praxis &#8211; Loan Amortization &#171; Bonsai Code]]></dc:creator>
		<pubDate>Tue, 12 May 2009 12:16:31 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=611#comment-104</guid>
		<description><![CDATA[[...] Praxis &#8211; Loan&#160;Amortization By Remco Niemeijer  Today’s Programming Praxis problem is about loan amortization. For those of you who, like me, had no idea [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Praxis &#8211; Loan&nbsp;Amortization By Remco Niemeijer  Today’s Programming Praxis problem is about loan amortization. For those of you who, like me, had no idea [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

