mtbakerguy/dcfun
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
This directory contains a couple of small scripts that show how to do
algorithms with recursive 'dc' macros. The scripts are listed below.
o exp.dc - bit of code that can compute logarithms and fractional exponents
o birthday.dc - compute the 'birthday paradox' probability for two numbers.
Call the script for the Wikipedia example in the following
manner: dc -f birthday.dc -e'365 23 lfx'
Result: 50.729800
o sum.dc - compute the sum for i=1 -> of 1/i.
Call the script in the following way: dc -f sum.dc -e'1000 lsx p'
Result: 9.3668
o simple model for estimating the cost of a release
Call the script in the following way:
dc -f releasecost.dc -e'numemployees_in_org percentage_of_employees_on_other_projects percentage_of_time_remaining_employees_spend_on_other_commitments periodic_budget number_of_periods'
Result: a dollar amount
Advice for people scripting 'dc':
o don't fight using registers in some ideological effort to only use the
stack. You are not using Forth.
o liberally sprinkle 'f' into your code to inspect the stack.
o the code will be short but your comments probably shouldn't be.
o test your snippets of code in tiny pieces and assemble the script
incrementally.
o it's addicting and feels vaguely like fun instead of work.