Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!apple!sun-barr!cs.utexas.edu!uunet!mcvax!kth!sunic!dkuug!freja!rimfaxe!damm From: damm@rimfaxe.diku.dk (Kristian Damm Jensen) Newsgroups: comp.lang.pascal Subject: Re: complex numbers Message-ID: <4658@freja.diku.dk> Date: 16 Jul 89 10:23:23 GMT References: <2751@ohstpy.mps.ohio-state.edu> <2360@pur-phy> Sender: news@freja.diku.dk Lines: 36 hal@pur-phy (Hal Chambers) writes: >In article <2751@ohstpy.mps.ohio-state.edu> heff@ohstpy.mps.ohio-state.edu writes: >>. . . to write equations in source code such as >> a =: b + c; >> a := (b+c)/(d+e); >>as can be done in fortran. For that matter, are there any languages beside >>fortran which allow easy computation of complex numbers? >Although Pascal (and Modula-2, etc.) allows the definition of a Complex >type, there is no way for the programmer to define the operators >other than as explicit procedure calls (functions can't return a >structured type). No, but you can return a pointer to a structured type. In fact I once received a whole packages of about 10K to do complex-arithmetic programmed that way. >So the examples above would appear as something like: > > a =: b + c; > cadd(a, b,c); or if you use functions as described a := cadd (b, c); > > a := (b+c)/(d+e); > cadd(c1, b,c); > cadd(c2, d,e); > cdiv(a, c1,c2); >Ugly!!!! a := cdiv (cadd (b, c), cadd (d, e)) with a, b, c, d and e being pointers to the records containing the complex numbers. Not to bad if yoy don't dislike a lisp-like programming style. ------------------------------------------------------------------------- Kristian Damm Jensen (damm@freja.diku.dk)