[pure-lang-svn] SF.net SVN: pure-lang: [400] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-07-06 10:50:04
|
Revision: 400 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=400&view=rev Author: agraef Date: 2008-07-06 03:50:05 -0700 (Sun, 06 Jul 2008) Log Message: ----------- Move '=>' constructor from dict.pure to prelude.pure. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/examples/dict.pure pure/trunk/lib/prelude.pure pure/trunk/test/prelude.log Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-07-06 10:06:08 UTC (rev 399) +++ pure/trunk/ChangeLog 2008-07-06 10:50:05 UTC (rev 400) @@ -1,5 +1,8 @@ 2008-07-06 Albert Graef <Dr....@t-...> + * lib/prelude.pure: Added new "mapsto" constructor. Requested by + Jiri Spitz. + * runtime.cc (pure_sys_vars): Turn system constants into real constant definitions. Modified: pure/trunk/examples/dict.pure =================================================================== --- pure/trunk/examples/dict.pure 2008-07-06 10:06:08 UTC (rev 399) +++ pure/trunk/examples/dict.pure 2008-07-06 10:50:05 UTC (rev 400) @@ -33,10 +33,6 @@ /* Empty tree constant, consider this private. */ nullary nil; -/* Definition of the mapsto operator used for key=>value pairs */ -infix 2 => ; - - /***** Tree for dict and hdict is either: - nil (empty tree) or Modified: pure/trunk/lib/prelude.pure =================================================================== --- pure/trunk/lib/prelude.pure 2008-07-06 10:06:08 UTC (rev 399) +++ pure/trunk/lib/prelude.pure 2008-07-06 10:50:05 UTC (rev 400) @@ -47,6 +47,7 @@ infixr 0 $ ; // right-associative application infixr 1 , ; // pair (tuple) +infix 2 => ; // mapsto constructor infixr 2 || ; // logical or (short-circuit) infixr 3 && ; // logical and (short-circuit) prefix 3 not ; // logical negation @@ -89,6 +90,13 @@ uncurry3 f (x,y,z) = f x y z; +/* "Mapsto" operator. This constructor is declared here so that it can be used + in other standard library modules to denote special kind of pairs which map + keys to values. Here we only define equality of such pairs. */ + +(x=>v)==(y=>w) = if x==y then v==w else 0; +(x=>v)!=(y=>w) = if x!=y then 1 else v!=w; + /* Poor man's tuples(TM). These are constructed with the pairing operator ',', are always flat and associate to the right. The empty tuple, denoted (), is neutral with respect to ','. Operations are provided to test for equality/ Modified: pure/trunk/test/prelude.log =================================================================== --- pure/trunk/test/prelude.log 2008-07-06 10:06:08 UTC (rev 399) +++ pure/trunk/test/prelude.log 2008-07-06 10:50:05 UTC (rev 400) @@ -10,6 +10,8 @@ curry3 f/*0:0001*/ x/*0:001*/ y/*0:01*/ z/*0:1*/ = f/*0:0001*/ (x/*0:001*/,y/*0:01*/,z/*0:1*/); uncurry f/*0:01*/ (x/*0:101*/,y/*0:11*/) = f/*0:01*/ x/*0:101*/ y/*0:11*/; uncurry3 f/*0:01*/ (x/*0:101*/,y/*0:1101*/,z/*0:111*/) = f/*0:01*/ x/*0:101*/ y/*0:1101*/ z/*0:111*/; +(x/*0:0101*/=>v/*0:011*/)==(y/*0:101*/=>w/*0:11*/) = if x/*0:0101*/==y/*0:101*/ then v/*0:011*/==w/*0:11*/ else 0; +(x/*0:0101*/=>v/*0:011*/)!=(y/*0:101*/=>w/*0:11*/) = if x/*0:0101*/!=y/*0:101*/ then 1 else v/*0:011*/!=w/*0:11*/; x/*0:01*/,() = x/*0:01*/; (),y/*0:1*/ = y/*0:1*/; (x/*0:0101*/,y/*0:011*/),z/*0:1*/ = x/*0:0101*/,y/*0:011*/,z/*0:1*/; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |