3 ms·
You get those also doing a Pascal triangle mod 2, so a xor. Is a zoom-out fractal as oposed to Mandelbrot set.
by jesuslop 1y ago
You get those also doing a Pascal triangle mod 2, so a xor. Is a zoom-out fractal as oposed to Mandelbrot set.
- anthk 1y agoTrue. pas.f in Forth : .r u.r ; : position ( row -- ) cr 33 swap 2 * - spaces ; : pas ( 0 ... 0 -- 0 ... 0 ) 0 >r begin over + >r dup 0= until begin r> dup while dup 4 .r repeat ; : pass ( -- ) 0 1 0 18 0 ?do dup position >r pas r> 1+ loop drop ; : pax ( 0 ... 0 -- ) drop begin 0= until ; : pascal ( -- ) pass pax ; pascal cr The same mod2: : .r u.r ; : position ( row -- ) cr 33 swap 2 * - spaces ; : pas ( 0 ... 0 -- 0 ... 0 ) 0 >r begin over + >r dup 0= until begin r> dup while dup 2 mod 4 .r repeat ; : pass ( -- ) 0 1 0 18 0 ?do dup position >r pas r> 1+ loop drop ; : pax ( 0 ... 0 -- ) drop begin 0= until ; : pascal ( -- ) pass pax ; pascal cr A Forth for people in a hurry: git clone https://github.com/howerj/subleq cd subleq sed -i 's,0 constant opt.control,1 constant opt.control,g' subleq.fth gmake subleq ./subleq subleq.dec < subleq.fth > new.dec ./subleq new.dec < pas.f
- kragen 1y agoOutput 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
- anthk 1y agoStraight 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
- kragen 1y agoThat 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.