[Checkins] SVN: Sandbox/adamg/ocql/trunk/src/ocql/rewriter/algebra.txt add more algebra function implementations for the corresponding declerations

Charith Paranaliyanage paranaliyanage at gmail.com
Fri Aug 15 03:18:40 EDT 2008


Log message for revision 89868:
  add more algebra function implementations for the corresponding declerations

Changed:
  U   Sandbox/adamg/ocql/trunk/src/ocql/rewriter/algebra.txt

-=-
Modified: Sandbox/adamg/ocql/trunk/src/ocql/rewriter/algebra.txt
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/rewriter/algebra.txt	2008-08-15 06:22:48 UTC (rev 89867)
+++ Sandbox/adamg/ocql/trunk/src/ocql/rewriter/algebra.txt	2008-08-15 07:18:40 UTC (rev 89868)
@@ -47,7 +47,6 @@
     >>> run(x)
     set([1, 2, 3])
 
-
     >>> x = Union(list, [1, 2], [2, 3])
     >>> x
     Union(<type 'list'>, [1, 2], [2, 3])
@@ -85,8 +84,8 @@
 The equal operations compare two collections of the same kind and return true
 if their elements are the same.
 Duplication and ordering, if respected, will be taken into account.
+not yet implemented in the system
 
-
 Unary Operations
 ----------------
 The operations described below are unary in the sense that each takes a
@@ -110,13 +109,22 @@
     >>> run(x)
     20
 
+    >>> x = Reduce(set, 0, 'lambda y: y+1', 'operator.add', [1, 2, 3, 4, 5])
+    >>> x
+    Reduce(<type 'set'>, 0, lambda y: y+1, operator.add, [1, 2, 3, 4, 5])
 
+    >>> run(x)
+    20
+
+
 Map ( F, C)
 -----------
 The map operations apply the operand function F to each element in the operand
 collection C and form a collection containing the results. The resultant
 collection and operand collection are of the same collection kind.
+not yet implemented in the system
 
+
 Select ( F, C )
 ---------------
 The select operation applies the operand boolean function F to each element
@@ -162,6 +170,7 @@
 -------------
 The index operation takes a list C and returns an element of the list at
 position E.
+not yet implemented in the system
 
 
 Simple Operations
@@ -227,8 +236,8 @@
 The and operation takes two boolean expressions and returns true if both of
 them evaluate to true. This is a non-commutative operation and the operands
 cannot be swapped.
+not yet implemented in the system
 
-
 Range ( E1, E2 )
 ----------------
 The range operations generate a collection containing integers within a given range.
@@ -249,3 +258,73 @@
 
     >>> run(x)
     [1, 2, 3]
+
+
+Iter ( F, C )
+-------------
+Iter function is a simple functions that can be applied to the elements of
+a collection. The semantics of iter is given by rules following
+(F - function, E - expression, C - collection. More details in document )
+    1 - iter ( F, empty ( nil ) ) = empty ( nil )
+    2 - iter ( F, single ( E ) ) = F E
+    3 - iter ( F, union ( C1, C2 ) ) = union ( iter ( F, C1 ), iter ( F, C2 ) )
+
+rule 1
+------
+	>>> from ocql.rewriter.algebra import Iter
+	>>> x = Iter(set, 'lambda z: z', Empty(set))
+	>>> x
+	Iter(<type 'set'>, lambda z: z, Empty(<type 'set'>))
+
+	>>> run(x)
+	set([])
+
+	>>> x = Iter(list, 'lambda z: z', Empty(list))
+	>>> x
+	Iter(<type 'list'>, lambda z: z, Empty(<type 'list'>))
+
+	>>> run(x)
+	[]
+
+rule 2
+------
+	>>> x = Iter(set, 'lambda z: z', Single(set, '"a"'))
+	>>> x
+	Iter(<type 'set'>, lambda z: z, Single(<type 'set'>, "a"))
+
+	>>> run(x)
+	set(['a'])
+
+rule 3
+------
+	>>> x = Iter(set, 'lambda z: z', Union(set, set(['a']), set(['b'])))
+	>>> x
+	Iter(<type 'set'>, lambda z: z, Union(<type 'set'>, set(['a']), set(['b'])))
+
+	>>> run(x)
+	set(['a', 'b'])
+
+	>>> x = Union(set, Iter(set, 'lambda z: z', Single(set, '"a"')), Iter(set, 'lambda z: z', Single(set, '"b"')))
+	>>> x
+	Union(<type 'set'>, Iter(<type 'set'>, lambda z: z, Single(<type 'set'>, "a")), Iter(<type 'set'>, lambda z: z, Single(<type 'set'>, "b")))
+
+	>>> run(x)
+	set(['a', 'b'])
+
+
+Constant ( E )
+--------------
+The constant operations take a value and return a constant.
+	>>> from ocql.rewriter.algebra import Constant
+    >>> x = Constant(1)
+    >>> x
+    `1`
+
+Identifier ( E )
+----------------
+The identifier operations take a value and return an identifier.
+	>>> from ocql.rewriter.algebra import Identifier
+    >>> x = Identifier('ocql')
+    >>> x
+    ocql
+   
\ No newline at end of file



More information about the Checkins mailing list