-- -- mandel-text.occ -- text example of a mandelbrot set in occam (non-parallel!) -- Copyright (C) 1997 Jim Moores -- COMPLEX32 code Copyright (C) 1997 D.C. Wood -- Modifications (C) 2001 Fred Barnes -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -- -- this is a self-standing program.. -- KRoC/Linux as of 1.3.0-pre2 doesn't have COMPLEX stuff DATA TYPE COMPLEX32 RECORD REAL32 real, imag: : REAL32 INLINE FUNCTION COMPLEX32ABSSQ (VAL COMPLEX32 x) IS (x[real]*x[real]) + (x[imag]*x[imag]): COMPLEX32 INLINE FUNCTION "+" (VAL COMPLEX32 x, y) IS [x[real] + y[real], x[imag] + y[imag]]: COMPLEX32 INLINE FUNCTION "**" (VAL COMPLEX32 x, y) IS [(x[real]*y[real]) - (x[imag]*y[imag]), (x[imag]*y[real]) + (x[real]*y[imag])]: INT FUNCTION calc (VAL COMPLEX32 a) INT count: VALOF INITIAL COMPLEX32 iter IS [0.0, 0.0]: SEQ count := 0 WHILE ((COMPLEX32ABSSQ (iter) < 4.0) AND (count < 200)) SEQ iter := (iter * iter) + a count := count + 1 RESULT count : PROC mandle (CHAN OF BYTE kyb, scr, err) VAL []BYTE table IS [' ','.',',',':',';','|','[','$','%','#']: SEQ j = -26 FOR 52 SEQ SEQ i = -64 FOR 128 VAL REAL32 x IS (REAL32 TRUNC i) / 32.0: VAL REAL32 y IS (REAL32 TRUNC j) / 16.0: err ! table[(calc ([x,y](COMPLEX32)) \ 10)] err ! '*n' :