Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Output from `cr pascal` in GForth:

 1 1 1 1 0 1 1 1 1 1 1 0 0 0 1 1 1 0 0 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 1 0 1 1 1 1 1 0 0 0 0 1 1 1 1 1 0 0 0 1 0 0 0 1 0 0 0 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 ok 
By changing `4 .r` to `bl + dup dup dup emit emit emit emit` I get this:

 !!!! !!!!!!!! !!!! !!!! !!!!!!!!!!!!!!!! !!!! !!!! !!!!!!!! !!!!!!!! !!!! !!!! !!!! !!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!! !!!! !!!!!!!! !!!!!!!! !!!! !!!! !!!! !!!! !!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!! !!!! !!!! !!!! !!!! !!!!!!!! !!!!!!!! !!!!!!!! !!!!!!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!! !!!! !!!!!!!! !!!!!!!! ok 
But this is not using bitwise AND, just the Pascal's triangle approach. (Interestingly, you can reformulate that as a neighborhood-2 2-state 1-dimensional cellular automaton pretty easily; it occurs in a couple of different guises in Wolfram's catalog.)

Here's an ASCII-art version that uses AND as Michał describes:

 32 value size : line cr size 0 do dup i and if bl else [char] # then dup emit emit loop drop ; : pasand size 0 do i line loop ; 
Running `pasand` then yields this:

 ################################################################ ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #### #### #### #### #### #### #### #### ## ## ## ## ## ## ## ## ######## ######## ######## ######## ## ## ## ## ## ## ## ## #### #### #### #### ## ## ## ## ################ ################ ## ## ## ## ## ## ## ## #### #### #### #### ## ## ## ## ######## ######## ## ## ## ## #### #### ## ## ################################ ## ## ## ## ## ## ## ## #### #### #### #### ## ## ## ## ######## ######## ## ## ## ## #### #### ## ## ################ ## ## ## ## #### #### ## ## ######## ## ## #### ## ok


Straight from the blog, too, from C to Forth:

 : sier cr 32 0 do 32 0 do i j and if ." " else ." * " then loop cr loop ; sier 
Output from eforth/subleq (with do...loop set in the config):

 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ok ok


That looks nicer than my version. But you should put the `cr` before the inner loop, not after it. That way you can remove the `cr` before the outer loop.


Nothing much to do with your great post, but I almost REALLY liked that first pyramid, but the last line being off threw me visually, so I had to straighten it out:

 1 1 1 1 0 1 1 1 1 1 1 0 0 0 1 1 1 0 0 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 1 0 1 1 1 1 1 0 0 0 0 1 1 1 1 1 0 0 0 1 0 0 0 1 0 0 0 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact