[pure-lang-svn] SF.net SVN: pure-lang: [401] pure/trunk/examples/dict.pure
Status: Beta
Brought to you by:
agraef
From: <js...@us...> - 2008-07-06 17:37:49
|
Revision: 401 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=401&view=rev Author: jspitz Date: 2008-07-06 10:37:53 -0700 (Sun, 06 Jul 2008) Log Message: ----------- Revert changes to equality/inequality tests after moving '=>' to prelude, fix typo. Modified Paths: -------------- pure/trunk/examples/dict.pure Modified: pure/trunk/examples/dict.pure =================================================================== --- pure/trunk/examples/dict.pure 2008-07-06 10:50:05 UTC (rev 400) +++ pure/trunk/examples/dict.pure 2008-07-06 17:37:53 UTC (rev 401) @@ -47,7 +47,7 @@ emptydict, emptyhdict: return the empty dict or bag dict xs, hdict xs; create a dict or hdict from list xs dictp d, hdictp d; check whether x is a dict or hdict -mkdict y xs, mkhdixt y xs: create dict or hdict from a list of keys and +mkdict y xs, mkhdict y xs: create dict or hdict from a list of keys and a constant value #d size of dict or hdict d @@ -461,19 +461,8 @@ = insert d [x, y]; // equality checks for dict and hdict -d1@(Dict _) == d2@(Dict _) = eq (members d1) (members d2) -with - eq [] [] = 1; - eq (x:xs) [] = 0; - eq [] (x:xs) = 0; - eq (x:xs) (y:ys) = if eq x y then eq xs ys else 0; +d1@(Dict _) == d2@(Dict _) = (members d1) == (members d2); - eq (x1::int => y1) (x2::int => y2) | - eq (x1::string => y1) (x2::string => y2) | - eq (x1 => y1) (x2 => y2) - = x1 == x2 && y1 == y2 -end; - d1@(Hdict _) == d2@(Hdict _) = if (all (member d1) (keys d2)) then @@ -484,19 +473,7 @@ // inequality checks for dict and hdict -d1@(Dict _) != d2@(Dict _) = neq (members d1) (members d2) -with - neq [] [] = 0; - neq (x:xs) [] = 1; - neq [] (x:xs) = 1; - neq (x:xs) (y:ys) = if neq x y then 1 else neq xs ys; - - neq (x1::int => y1) (x2::int => y2) | - neq (x1::string => y1) (x2::string => y2) | - neq (x1 => y1) (x2 => y2) - = x1 != x2 || y1 != y2 -end; - +d1@(Dict _) != d2@(Dict _) = (members d1) != (members d2); d1@(Hdict _) != d2@(Hdict _) = not (d1 == d2); /* Private functions, don't invoke these directly. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |