Commits

T. Michael Keesey  committed f7d4ffe

Added function composition.

  • Participants
  • Parent commits 960cdcf

Comments (0)

Files changed (5)

File asmathema/.flexLibProperties

     <classEntry path="asmathema.flex.renderers.PhantomPolicy"/>
     <classEntry path="asmathema.operators.Ident"/>
     <classEntry path="asmathema.flex.renderers.ConvertingRendererFactory"/>
+    <classEntry path="asmathema.operators.Compose"/>
   </includeClasses>
   <includeResources/>
   <namespaceManifests/>

File asmathema/src/asmathema/mathML/evaluators/MathMLEvaluator.as

  */
 package asmathema.mathML.evaluators
 {
-	import flash.utils.Dictionary;
-	import flash.utils.getQualifiedClassName;
 	import asmathema.collections.lists.List;
 	import asmathema.collections.lists.VectorList;
 	import asmathema.collections.sets.FiniteSetBuilder;
 	import asmathema.operators.Operators;
 	import asmathema.relations.Relation;
 	import asmathema.relations.Relations;
+	
+	import flash.utils.Dictionary;
+	import flash.utils.getQualifiedClassName;
 
 	/**
 	 * Evaluates MathML-Content.
 			const d:Dictionary = new Dictionary();
 			d[MathMLContent.AND.localName] = Relations.AND;
 			d[MathMLContent.EMPTYSET.localName] = Sets.EMPTY_SET;
+			d[MathMLContent.COMPOSE.localName] = Operators.COMPOSE;
 			d[MathMLContent.EQ.localName] = Relations.EQ;
 			d[MathMLContent.FALSE.localName] = false;
 			d[MathMLContent.IDENT.localName] = Operators.IDENT;

File asmathema/src/asmathema/operators/Compose.as

+package asmathema.operators
+{
+	import asmathema.functions.MathFunction;
+	
+	import flashx.textLayout.operations.CompositeOperation;
+
+	public final class Compose implements Operator
+	{
+		public function Compose()
+		{
+			super();
+		}
+		
+		public function acceptsNArgs(nArgs:uint):Boolean
+		{
+			return nArgs >= 2;
+		}
+		
+		public function apply(args:Vector.<Object>):Object
+		{
+			return new CompositeOperator(args);
+		}
+		
+		public function argType(index:uint):Class
+		{
+			return MathFunction;
+		}
+	}
+}

File asmathema/src/asmathema/operators/CompositeOperator.as

 */
 package asmathema.operators
 {
-	import flash.utils.Proxy;
 	import asmathema.collections.FiniteCollection;
 	import asmathema.collections.lists.VectorList;
+	
+	import flash.utils.Proxy;
 
 	public final class CompositeOperator implements Operator
 	{
-		public function CompositeOperator(... suboperators)
+		public function CompositeOperator(suboperators:Object)
 		{
 			super();
-			const n:uint = suboperators.length;
-			if (n < 2)
-				throw new ArgumentError();
-			this.suboperators = new Vector.<Operator>(n);
+			this.suboperators = new Vector.<Operator>();
 			var i:uint = 0;
 			for each (var operator:Operator in suboperators)
 			{
 				if (operator == null)
 					throw new ArgumentError();
-				this.suboperators[i++] = operator;
+				this.suboperators.push(operator);
 			}
+			if (this.suboperators.length < 2)
+				throw new ArgumentError("There must be at least two operators within a composite operator.");
+			this.suboperators.fixed = true;
 		}
 		private var suboperators:Vector.<Operator>;
 

File asmathema/src/asmathema/operators/Operators.as

 
 	public final class Operators
 	{
+		public static const COMPOSE:Operator = new Compose();
 		public static const IDENT:Operator = new Ident();
 		public static const IN:Operator = new In();
 		public static const INTERSECT:Operator = new Intersect();