|
Introduction to Var'aq Programming |
This Site is intended to provide helps to Var'aq language programmers around the world through technical examples, informational articles, and personal assistance.
The following examples are meant to be a quick Getting Started sort of tutorial using the varaq-kling.pl version in Perl.
Example 5. Depreciation Calculator
Now we will take a look at doing a calculation in Var'aq. I grant that this
is a very UN-Klingon example, but if ngabwI' can compute quantities for
home-made soap, I think depreciation is okay. :)
(* sldep -- straight-line depreciation calculator *)
(* Requires: cost, salvage_value, and years to depreciate *)
(* cost salvage_value years --- depreciation *)
"sldep" (* push the name of the function onto the stack. *)
{
"years" cher (* store the top item of the stack into "years". *)
boqHa' (* subtract the salvage_value from the cost, *)
(* the result is returned to the stack. *)
years (* push the "years" value onto the stack. *)
boqHa''egh (* divide (cost - salvage_value) by "years", *)
(* the result is returned to the stack. *)
}
pong (* store the function into the name "sldep" above. *)
20000 0 5 sldep cha' (* run the function, and print the result: 4000 *)
The above code should compute straight-line depreciation and print the result.
Here is the code without the comments:
"sldep" { "years" cher boqHa' years boqHa''egh } pongGo back to go to the next example.