Last active
October 5, 2016 15:40
-
-
Save astynax/24681fbdaa72f32a9a6ac6b24b22a32b to your computer and use it in GitHub Desktop.
Pine tree in gforth
This file contains hidden or 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
( Program which prints a pine tree ) | |
: star ( -- ) ." *" ; | |
: stars ( n -- ) 0 do star loop ; | |
: padd ( n1 n2 -- ) - spaces ; | |
: row ( n1 n2 -- n1 ) 2dup padd dup + 1- stars ; | |
: tree ( n -- ) dup 1 do I row cr loop ; | |
( Run with | |
gforth tree.fs -e "10 tree bye" | |
* | |
*** | |
***** | |
******* | |
********* | |
*********** | |
************* | |
*************** | |
***************** | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment