User talk:Balrog: Difference between revisions

(Showing my buddy Nick how to add sample code to his discussion page)
 
(2 intermediate revisions by 2 users not shown)
Line 6:
:Thanks. Alas, he hasn't. --[[User:Balrog|Balrog]] 23:12, 18 June 2009 (UTC)
 
==Complex==
 
You might want to consider linking your complex solution into the Go part of [[Unicode variable names]]. Thanks. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 09:55, 2 November 2014 (UTC)
 
:Thanks. I hadn't noticed that one. I think you mean "Groovy part" though --[[User:Balrog|Balrog]] ([[User talk:Balrog|talk]]) 04:12, 3 November 2014 (UTC)
 
== Like This, Nick ==
<lang clojure>
(def tables [[10 0 8500]
[15 8501 34500]
[25 34501 83600]
[28 83601 174400]
[33 174401 379150]
[35 379151 Long/MAX_VALUE]])
 
(defn tax-calc
"Takes a dollar amount value and returns your federal tax obligation based on
the table above"
[taxable-income]
(second (reduce (fn [[dec-income calc] [percentage start end]]
(if (< start taxable-income)
(let[limit (min taxable-income end)
taxable-range (- limit start)
result (float (* (/ percentage 100) taxable-range))
dec-income (- dec-income (min taxable-range dec-income))]
[dec-income (+ calc result)])
[dec-income calc])) [taxable-income 0]
tables)))
</lang>
Anonymous user