public void EvalThen(RCRunner runner, RCClosure closure, RCBoolean left, RCBlock right) { if (left[0]) { int i = closure.Index - 2; if (i < left.Count) { RCClosure child = new RCClosure(closure, closure.Bot, right, closure.Left, RCBlock.Empty, 0); right.Eval(runner, child); } else { runner.Yield(closure, closure.Parent.Result); } } else { runner.Yield(closure, RCBoolean.False); } }
public void EvalChart(RCRunner runner, RCClosure closure, RCBoolean right) { RCCube result = new RCCube(new RCArray <string> ("S")); DoChart <bool> (result, RCSymbolScalar.Empty, 0, 0, right); runner.Yield(closure, result); }
protected RCBlock RecursiveWhere(RCBlock left, RCBlock right) { if (left.Count != right.Count) { throw new Exception(string.Format( "Left count was {0} but right count was {1}. Counts must match", left.Count, right.Count)); } RCBlock result = RCBlock.Empty; for (int i = 0; i < left.Count; ++i) { RCBlock leftName = left.GetName(i); RCValue rightValue = right.Get(i); if (rightValue is RCBlock) { RCBlock rightBlock = (RCBlock)rightValue; RCBlock leftBlock = left.GetBlock(i); RCBlock childResult = RecursiveWhere(leftBlock, rightBlock); if (childResult.Count > 0) { result = new RCBlock(result, leftName.Name, leftName.Evaluator, childResult); } } else if (rightValue is RCBoolean) { if (rightValue.Count == 1) { if (right.GetBoolean(i)) { result = new RCBlock(result, leftName.Name, ":", leftName.Value); } } else { RCBoolean rightVector = (RCBoolean)rightValue; RCBlock leftBlock = left.GetBlock(i); RCBlock childResult = RCBlock.Empty; for (int j = 0; j < rightVector.Count; ++j) { RCBlock leftVar = leftBlock.GetName(j); if (rightVector[j]) { childResult = new RCBlock(childResult, leftVar.Name, ":", leftVar.Value); } } if (childResult.Count > 0) { result = new RCBlock(result, leftName.Name, leftName.Evaluator, childResult); } } } } return(result); }
public void EvalTree(RCRunner runner, RCClosure closure, RCBoolean right) { RCCube result = new RCCube(new RCArray <string> ("S")); TreeNode root = new TreeNode(RCSymbolScalar.Empty, RCSymbolScalar.Empty); root.children = new RCArray <TreeNode> (); DoTree <bool> (root, right, ref root.n, ref root.g, Areab, Formatb); LayoutBottomUp(root, 0); LayoutTree(0, root); WriteTree(result, root); runner.Yield(closure, result); }
public void EvalSwitch(RCRunner runner, RCClosure closure, RCBoolean left, RCBlock right) { Picker <bool> picker = delegate(bool val, out bool eval) { long i = val ? 0 : 1; RCBlock variable = right.GetName(i); eval = !variable.Evaluator.Pass; return(i >= right.Count ? RCBlock.Empty : variable.Value); }; DoSwitch <bool> (runner, closure, left, right, picker); }
public void EvalWhere(RCRunner runner, RCClosure closure, RCBoolean right) { RCArray <long> result = new RCArray <long> (8); for (int i = 0; i < right.Count; ++i) { if (right[i]) { result.Write((long)i); } } runner.Yield(closure, new RCLong(result)); }
public void EvalWhere(RCRunner runner, RCClosure closure, RCBlock left, RCBoolean right) { RCBlock result = RCBlock.Empty; for (int i = 0; i < right.Count; ++i) { if (right[i]) { RCBlock current = left.GetName(i); result = new RCBlock(result, current.Name, current.Evaluator, current.Value); } } runner.Yield(closure, result); }
public void EvalSort(RCRunner runner, RCClosure closure, RCSymbol left, RCBoolean right) { runner.Yield(closure, new RCBoolean(DoSort <bool> (ToDir(left), right))); }
public void EvalSort(RCRunner runner, RCClosure closure, RCBoolean right) { runner.Yield(closure, new RCBoolean(DoSort <bool> (SortDirection.asc, right))); }
public void EvalExcept(RCRunner runner, RCClosure closure, RCBoolean left, RCBoolean right) { runner.Yield(closure, new RCBoolean(DoExcept <bool> (left, right))); }
public void EvalFrom(RCRunner runner, RCClosure closure, RCByte left, RCBoolean right) { runner.Yield(closure, DoAt <bool> (closure, right, left)); }
public void EvalFirst(RCRunner runner, RCClosure closure, RCBoolean right) { runner.Yield(closure, new RCBoolean(right[0])); }
public void EvalLast(RCRunner runner, RCClosure closure, RCBoolean right) { runner.Yield(closure, new RCBoolean(right[right.Count - 1])); }
public void EvalRepeat(RCRunner runner, RCClosure closure, RCLong left, RCBoolean right) { runner.Yield(closure, new RCBoolean(DoRepeat <bool> (left, right))); }
public void EvalWhere(RCRunner runner, RCClosure closure, RCByte left, RCBoolean right) { runner.Yield(closure, DoWhere <byte> (left, right)); }
public void EvalWhere(RCRunner runner, RCClosure closure, RCString left, RCBoolean right) { runner.Yield(closure, DoWhere <string> (left, right)); }
public void EvalWhere(RCRunner runner, RCClosure closure, RCIncr left, RCBoolean right) { runner.Yield(closure, DoWhere <RCIncrScalar> (left, right)); }
public void EvalWhere(RCRunner runner, RCClosure closure, RCDecimal left, RCBoolean right) { runner.Yield(closure, DoWhere <decimal> (left, right)); }
public void EvalAppend(RCRunner runner, RCClosure closure, RCBoolean left, RCBoolean right) { runner.Yield(closure, new RCBoolean(DoAppend <bool> (left, right))); }
public void EvalOperator(RCRunner runner, RCClosure closure, RCBoolean left, RCByte right) { runner.Yield(closure, DoAt <bool> (closure, left, right)); }
public void EvalShuffle(RCRunner runner, RCClosure closure, RCLong left, RCBoolean right) { runner.Yield(closure, new RCBoolean(DoShuffle <bool> (new Random((int)left[0]), right))); }
public void EvalFlag(RCRunner runner, RCClosure closure, RCBoolean left, RCString right) { bool result = RCSystem.Args.Options.GetBoolean(right[0], left[0]); runner.Yield(closure, new RCBoolean(result)); }
public void EvalCount(RCRunner runner, RCClosure closure, RCBoolean right) { runner.Yield(closure, new RCLong(right.Count)); }
public void EvalUnique(RCRunner runner, RCClosure closure, RCBoolean right) { runner.Yield(closure, new RCBoolean(DoUnique <bool> (right))); }
public void EvalOperator(RCRunner runner, RCClosure closure, RCBoolean left, RCBoolean right) { runner.Yield(closure, DoFind <bool> (left, right)); }
public void EvalRank(RCRunner runner, RCClosure closure, RCBoolean right) { runner.Yield(closure, new RCLong(RankUtils.DoRank <bool> (SortDirection.asc, right))); }
public void EvalPop(RCRunner runner, RCClosure closure, RCBoolean right) { runner.Yield(closure, new RCBoolean(DoPop <bool> (right.Data))); }
public void EvalRank(RCRunner runner, RCClosure closure, RCSymbol left, RCBoolean right) { runner.Yield(closure, new RCLong(RankUtils.DoRank <bool> (Sort.ToDir(left), right))); }
public void EvalUnion(RCRunner runner, RCClosure closure, RCBoolean left, RCBoolean right) { runner.Yield(closure, new RCBoolean(DoUnion <bool> (left, right))); }
public void EvalAppend(RCRunner runner, RCClosure closure, RCBlock right) { if (right.Count == 0) { runner.Yield(closure, RCBlock.Empty); } RCValue first = right.Get(0); RCVectorBase vector = first as RCVectorBase; if (vector != null) { RCVectorBase result; switch (vector.TypeCode) { case 'x': result = new RCByte(DoAppend <byte> (right)); break; case 'l': result = new RCLong(DoAppend <long> (right)); break; case 'd': result = new RCDouble(DoAppend <double> (right)); break; case 'm': result = new RCDecimal(DoAppend <decimal> (right)); break; case 's': result = new RCString(DoAppend <string> (right)); break; case 'b': result = new RCBoolean(DoAppend <bool> (right)); break; case 'y': result = new RCSymbol(DoAppend <RCSymbolScalar> (right)); break; case 't': result = new RCTime(DoAppend <RCTimeScalar> (right)); break; default: throw new Exception("Type:" + vector.TypeCode + " is not supported by sort"); } runner.Yield(closure, result); return; } RCCube cube = first as RCCube; if (cube != null) { RCCube result = new RCCube(cube); for (int i = 1; i < right.Count; ++i) { Writer writer = new Writer(result, null, true, true, 0); writer.Write((RCCube)right.Get(i)); } runner.Yield(closure, result); return; } // Individual values are now appended to the result just like the children of // blocks. { RCBlock result = RCBlock.Empty; for (int i = 0; i < right.Count; ++i) { RCBlock top = right.GetName(i); if (top.Value is RCBlock) { RCBlock list = (RCBlock)right.Get(i); for (int j = 0; j < list.Count; ++j) { RCBlock item = list.GetName(j); result = new RCBlock(result, item.Name, ":", item.Value); } } else { result = new RCBlock(result, top.Name, ":", top.Value); } } runner.Yield(closure, result); } }