Skip to content

Instantly share code, notes, and snippets.

@astynax
Last active October 5, 2016 15:40
Show Gist options
  • Save astynax/24681fbdaa72f32a9a6ac6b24b22a32b to your computer and use it in GitHub Desktop.
Save astynax/24681fbdaa72f32a9a6ac6b24b22a32b to your computer and use it in GitHub Desktop.
Pine tree in gforth
( 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