develooper Front page | perl.perl6.language | Postings from April 2005

Adding Complexity

Thread Next
Jonathan Lang
April 26, 2005 20:49
Adding Complexity
Message ID:
As an exercise, I've been looking into what could be  done in terms of
creating a complex numbers package that takes advantage of perl 6
technology.  A couple of thoughts that I ran across:

When you take the square root of a number, you actually get one of two
possible answers (for instance, sqrt(1) actually gives either a 1 or a
-1).  This sounds like an appropriate place to return an ajunction. 
Extending this philosophy a bit, note that any time that a complex number
is raised to a rational power, you get a finite number of possible
answers, which could likewise be handled as an ajunction of a list of the
possible answers.  

Admittedly, the list could conceivably get to be quite long: raising a
number to the 0.01 power, for instance, would result in a list of a
hundred possible solutions.  And matters get even messier when the power
is irrational (such as pi), in which case the list becomes infinite in
length.  IIRC, this is exactly what lazy lists are for.  

So what happens when you apply a junction to a lazy list?  Do you get a
"lazy junction"?  

Jonathan "Dataweaver" Lang

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About