[pure-lang-svn] SF.net SVN: pure-lang: [64] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-05-06 17:12:28
|
Revision: 64 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=64&view=rev Author: agraef Date: 2008-05-06 10:12:35 -0700 (Tue, 06 May 2008) Log Message: ----------- Add a definition for the ^ operator. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/lib/prelude.pure pure/trunk/lib/primitives.pure Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-06 17:01:15 UTC (rev 63) +++ pure/trunk/ChangeLog 2008-05-06 17:12:35 UTC (rev 64) @@ -1,8 +1,8 @@ 2008-05-06 Albert Graef <Dr....@t-...> * lib/primitives.pure: Made the pow function work with all - combinations of integer and double arguments. Added the sqrt - function. + combinations of integer and double arguments. Also added the sqrt + function and the ^ operator. * runtime.cc, lib/primitives.pure: Added predicates funp, lambdap, varp checking for named and anonymous closures and unbound global Modified: pure/trunk/lib/prelude.pure =================================================================== --- pure/trunk/lib/prelude.pure 2008-05-06 17:01:15 UTC (rev 63) +++ pure/trunk/lib/prelude.pure 2008-05-06 17:12:35 UTC (rev 64) @@ -47,7 +47,7 @@ infixl 6 + - | ; // addition, bitwise or infixl 7 * / div mod & ; // multiplication, bitwise and prefix 7 ~ ; // bitwise not -infixr 8 ^ ; // exponentiation (undefined for now) +infixr 8 ^ ; // exponentiation prefix 8 # ; // size operator infixl 9 ! ; // indexing infixr 9 . ; // function composition Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-05-06 17:01:15 UTC (rev 63) +++ pure/trunk/lib/primitives.pure 2008-05-06 17:12:35 UTC (rev 64) @@ -283,6 +283,19 @@ pow x::int y::double = c_pow (double x) y if x>=0 || int y==y; pow x::bigint y::double = c_pow (double x) y if x>=0 || int y==y; +/* The ^ operator. Works like pow, but always promotes its operands to double + and returns a double result. */ + +x::double^y::double = c_pow x y if x>=0 || int y==y; +x::int^y::int = c_pow (double x) (double y); +x::bigint^y::bigint = c_pow (double x) (double y); +x::int^y::bigint = c_pow (double x) (double y); +x::bigint^y::int = c_pow (double x) (double y); +x::double^y::int = c_pow x (double y); +x::double^y::bigint = c_pow x (double y); +x::int^y::double = c_pow (double x) y if x>=0 || int y==y; +x::bigint^y::double = c_pow (double x) y if x>=0 || int y==y; + /* Pointer arithmetic. We do this using bigints, so that the code is portable to 64 bit systems. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |