Created
December 6, 2009 07:28
-
-
Save lsparrish/250116 to your computer and use it in GitHub Desktop.
Refactored pad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable addr | |
::: Power function | |
: pow ( bp-n ) | |
over here ! ::: Store the base for later use. | |
1 - 0; ::: Subtract 1 from the power and exit if the result is 0. | |
for here @ * next ; ::: Fetch the base and multiply it by the number. | |
::: Get the top value from the address stack. | |
: r ( -n ) ` pop ` dup ` push ; immediate | |
: pad ( - ) | |
addr @ @ ::: Get the value pointed to by addr. | |
6 for dup ::: Handle up to 6 digits. | |
base @ r pow ::: Multiply the base by itself, a given number of times. | |
<if 32 emit then next ::: When the number is less than the smallest number | |
::: that takes up the given number of columns, | |
::: begin emitting spaces. | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment