12 Jan
2003
12 Jan
'03
7:29 p.m.
Hal Daume III writes: : | So, you're probably better off with: | | > nco wn = nco' | > where wn' = cis wn | > nco' = 1 : map (wn'*) nco' | | In which case it will only be evaluated once. The following version also evaluates 'cis wn' only once.
nco wn = iterate (cis wn *) 1
I've only tested this in hugs with no command line flags, and can't explain the theory offhand.
import Complex() import Trace cis t = trace "\ncis\n" (Complex.cis t) nco wn = iterate (cis wn *) 1
Main> take 5 (nco (pi/2)) [1.0 :+ 0.0, cis (-4.37114e-08) :+ 1.0,(-1.0) :+ (-8.74228e-08),1.31134e-07 :+ (-1.0),1.0 :+ 1.74846e-07] Regards, Tom