Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: do I win the "most pointless use of ZSH" award? ;)



On Mon, Apr 30, 2001 at 12:41:25PM -0700, David Terrell wrote:
> www.meat.net/~dbt/zsh-overkill2.png
> 
> time says:
> ./bin/mandelbrot.zsh  65983.75s user 2255.87s system 31% cpu 59:51:22.92 total
> % echo $LINES $COLUMNS
> 360 1000

Hi, just for what it's worth, with the help of Bart Schaefer I've
managed to optimise the code a bit! It also looks a bit more
interesting whilst it's drawing than before... :)

#!/bin/zsh

((columns=COLUMNS-1, lines=LINES))
((colour=0))

for ((b=-1.5;b<=1.5;b+=3.0/lines));do
    for ((a=-2.0;a<=1;a+=3.0/columns));do

	for (( p=0.0, q=0.0, i=0 ; p*p+q*q < 4 && i < 32 ; i++));do
	    ((pnew=p*p-q*q+a, q=2*p*q+b, p=pnew))
	done

	((colour=(i/4)%8))

	echo -n "\\e[4${colour}m "
    done
done

-- 
Alan Third



Messages sorted by: Reverse Date, Date, Thread, Author