/// <summary> /// Initialize from given metatadata, plus first, restFn, rest. /// </summary> /// <param name="meta">The metadata to attach</param> /// <param name="first">The first of the sequence.</param> /// <param name="restFn">The function to generate the next value.</param> /// <param name="rest">The rest of the sequence..</param> FnSeq(IPersistentMap meta, object first, IFn restFn, ISeq rest) : base(meta) { _first = first; _restFn = restFn; _rest = rest; }
public object reduce(IFn f, object start) { object ret = f.invoke(start, _array[_off]); for (int x = _off + 1; x < _end; x++) ret = f.invoke(ret, _array[x]); return ret; }
public static Delegate Create(Type delegateType, IFn fn) { MethodInfo invokeMI = delegateType.GetMethod("Invoke"); Type returnType = invokeMI.ReturnType; ParameterInfo[] delParams = invokeMI.GetParameters(); List<ParameterExpression> parms = new List<ParameterExpression>(); List<Expression> callArgs = new List<Expression>(); foreach (ParameterInfo pi in delParams) { ParameterExpression pe = Expression.Parameter(pi.ParameterType, pi.Name); parms.Add(pe); callArgs.Add(MaybeBox(pe)); } Expression call = Expression.Call( Expression.Constant(fn), Compiler.Methods_IFn_invoke[parms.Count], callArgs); Expression body = returnType == typeof(void) ? (Expression)Expression.Block(call,Expression.Default(typeof(void))) : (Expression)Expression.Convert(call, returnType); LambdaExpression lambda = Expression.Lambda(delegateType, body, true, parms); return lambda.Compile(); }
public IFn tap() { if (_tap != null) throw new InvalidOperationException("Stream already tapped"); return _tap = makeTap(_xform, _src); }
public void UpdateSettings(DataSource_ClojureFunction_Config sender) { minXVal = sender.MinX; maxXVal = sender.MaxX; minYVal = sender.MinY; maxYVal = sender.MaxY; precision = sender.Precision; clojureFunctionText1 = sender.ClojureFunction1.Trim(); clojureFunctionText2 = sender.ClojureFunction2.Trim(); clojureFunction1 = null; clojureFunction2 = null; if (clojureFunctionText1 != "") { try { clojureFunction1 = (IFn)ClojureEngine.EvalRaw("(fn [x y z t] " + clojureFunctionText1 + ")"); } catch { } } if (clojureFunctionText2 != "") { try { clojureFunction2 = (IFn)ClojureEngine.EvalRaw("(fn [x y z t] " + clojureFunctionText2 + ")"); } catch { } } }
public Future(IFn fn) { // TODO: Use a cached thread pool when agents have one. _t = new Thread(new ParameterizedThreadStart(ComputeFuture)); _t.Name = "Future"; _t.Start(fn); }
private Iterate(IPersistentMap meta, IFn f, Object prevSeed, Object seed, ISeq next) :base(meta) { _f = f; _prevSeed = prevSeed; _seed = seed; _next = next; }
public object deref() { if (_fn != null) { _val = _fn.invoke(); _fn = null; } return _val; }
/// Construct a multifunction. /// </summary> /// <param name="name">The name</param> /// <param name="dispatchFn">The dispatch function.</param> /// <param name="defaultDispatchVal">The default dispatch value.</param> /// <param name="hierarchy">The hierarchy for this multifunction</param> public MultiFn(string name, IFn dispatchFn, object defaultDispatchVal, IRef hierarchy) { _name = name; _dispatchFn = dispatchFn; _defaultDispatchVal = defaultDispatchVal; _methodTable = PersistentHashMap.EMPTY; _methodCache = MethodTable; _preferTable = PersistentHashMap.EMPTY; _hierarchy = hierarchy; _cachedHierarchy = null; }
public object reduce(IFn f, object start) { object ret = f.invoke(start, _array[_off]); if (RT.isReduced(ret)) return ret; for (int x = _off + 1; x < _end; x++) { ret = f.invoke(ret, _array[x]); if (RT.isReduced(ret)) return ((IDeref)ret).deref(); } return ret; }
public object swap(IFn f) { for (; ; ) { object v = deref(); object newv = f.invoke(v); Validate(newv); if (_state.CompareAndSet(v, newv)) { NotifyWatches(v,newv); return newv; } } }
/// <summary> /// Invoke an <see cref="IFn">IFn</see> on a value to validate it. /// </summary> /// <param name="vf">The <see cref="IFn">IFn</see> to invoke.</param> /// <param name="val">The value to validate.</param> /// <remarks>Uneventful return marks a successful validation. /// To indicate a failed validation, the validation function should return <value>false</value> or throw an exception. /// <para>This appears in multiple places. Should find it a common home?</para></remarks> protected internal static void Validate(IFn vf, object val) { if (vf == null) return; bool ret = false; try { ret = RT.booleanCast(vf.invoke(val)); } catch (Exception e) { throw new InvalidOperationException("Invalid reference state", e); } if ( ! ret ) throw new InvalidOperationException("Invalid reference state"); }
public static void AddClojureDropDownBox(string labelText, Var variable, PersistentVector vals, IFn func) { string variableSymbolName = null; if(variable != null) variableSymbolName = variable.sym.Name; Label label = new Label(); label.AutoSize = true; label.Text = labelText; Dictionary<string, object> labelCodeAssoc = new Dictionary<string, object>(); ComboBox comboBox = new ComboBox(); for (int i = 0; i < vals.Count; i += 2) { labelCodeAssoc.Add(vals[i].ToString(), vals[i + 1]); comboBox.Items.Add(vals[i]); } comboBox.SelectedIndex = 0; comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.SelectedIndexChanged += (s, e) => { if (comboBox.SelectedItem == null) return; object code = labelCodeAssoc[comboBox.SelectedItem.ToString()]; if(variableSymbolName != null) { string newVal = code.ToString(); ClojureEngine.Eval("(def " + variableSymbolName + " " + newVal + ")"); } if (func != null) ClojureEngine.Log(func.invoke()); }; self.AddNewClojureControls(new Control[] { label, comboBox }); }
public static IEnumerator create(IFn xform, IEnumerator source) { return(new TransformerEnumerator(xform, source, false)); }
public static object ApplyToHelper(IFn fn, ISeq argList) { switch (RT.BoundedLength(argList, 20)) { case 0: argList = null; return fn.invoke(); case 1: return fn.invoke(Util.Ret1(argList.first(),argList=null)); case 2: return fn.invoke(argList.first() , Util.Ret1((argList = argList.next()).first(),argList = null) ); case 3: return fn.invoke(argList.first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 4: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 5: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 6: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 7: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 8: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 9: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 10: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 11: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 12: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 13: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 14: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 15: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 16: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 17: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 18: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 19: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); case 20: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) ); default: return fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , RT.SeqToArray<object>(Util.Ret1(argList.next(),argList=null))); } }
/// <summary> /// Create an encapsulated message to an agent. /// </summary> /// <param name="agent">The agent the message is for.</param> /// <param name="fn">The function to compute the new value.</param> /// <param name="args">Additional arguments (in addition to the current state).</param> /// <param name="solo">Execute on its own thread?</param> public Action(Agent agent, IFn fn, ISeq args, bool solo) { _agent = agent; _fn = fn; _args = args; _solo = solo; }
public void setErrorHandler(IFn f) { _errorHandler = f; }
/// <summary> /// Construct one. /// </summary> /// <param name="fn">The function to invoke.</param> /// <param name="args">The arguments to invoke the function on.</param> public CFn(IFn fn, ISeq args) { _fn = fn; _args = args; }
/// <summary> /// Send a message to the agent. /// </summary> /// <param name="fn">The function to be called on the current state and the supplied arguments.</param> /// <param name="args">The extra arguments to the function.</param> /// <param name="solo"><value>true</value> means execute on its own thread (send-off); /// <value>false</value> means use a thread pool thread (send).</param> /// <returns>This agent.</returns> public object dispatch(IFn fn, ISeq args, Boolean solo) { if ( _errors != null ) throw new Exception("Agent has errors", (Exception)RT.first(_errors)); Action action = new Action(this,fn,args,solo); DispatchAction(action); return this; }
public DocumentService(IGetUserService getUserService, IRepository <Document> repository, IFn fn) { _getUserService = getUserService; _repository = repository; _fn = fn; }
public Stream(IFn xform, Stream src) { _src = src.tap(); _xform = xform; }
/// <summary> /// Sets the validator. /// </summary> /// <param name="vf">The new validtor</param> /// <remarks>The current value must validate in order for this validator to be accepted. If not, an exception will be thrown.</remarks> public virtual void setValidator(IFn vf) { Validate(vf, deref()); _validator = vf; }
public Stream(IFn src) { _src = src; _xform = null; }
static IFn makeTap(IFn xform, IFn src) { return(new Tapper(xform, src)); }
/// <summary> /// Construct a delay for a function. /// </summary> /// <param name="fn">The function to delay.</param> public Delay(IFn fn) { _fn = fn; _val = null; }
public object alter(IFn fn, ISeq args) { set(fn.applyTo(RT.cons(deref(), args))); return(this); }
public object reduce(IFn f) { throw new InvalidOperationException(); }
public static object read(PushbackTextReader r, bool eofIsError, object eofValue, bool isRecursive, Object opts) { try { for (; ;) { int ch = r.Read(); while (isWhitespace(ch)) { ch = r.Read(); } if (ch == -1) { if (eofIsError) { throw new EndOfStreamException("EOF while reading"); } return(eofValue); } if (Char.IsDigit((char)ch)) { object n = readNumber(r, (char)ch); return(RT.suppressRead() ? null : n); } IFn macroFn = getMacro(ch); if (macroFn != null) { object ret = macroFn.invoke(r, (char)ch, opts); if (RT.suppressRead()) { return(null); } // no op macros return the reader if (ret == r) { continue; } return(ret); } if (ch == '+' || ch == '-') { int ch2 = r.Read(); if (Char.IsDigit((char)ch2)) { Unread(r, ch2); object n = readNumber(r, (char)ch); return(RT.suppressRead() ? null : n); } Unread(r, ch2); } //string token = readToken(r, (char)ch); //return RT.suppressRead() ? null : interpretToken(token); string rawToken; string token; string mask; bool eofSeen; readToken(r, (char)ch, true, out rawToken, out token, out mask, out eofSeen); if (eofSeen) { if (eofIsError) { throw new EndOfStreamException("EOF while reading symbol"); } return(eofValue); } return(RT.suppressRead() ? null : InterpretToken(rawToken, token, mask)); } } catch (Exception e) { if (isRecursive) { throw; } LineNumberingTextReader lntr = r as LineNumberingTextReader; if (lntr == null) { throw; } throw new ReaderException(lntr.LineNumber, lntr.ColumnNumber, e); } }
void CommuteRoot(IFn fn) { object newRoot = fn.invoke(_root); Validate(getValidator(), newRoot); object oldRoot = _root; _root = newRoot; ++_rev; NotifyWatches(oldRoot, newRoot); }
public IntervalData(IFn _f, int _interval, object _key) { f = _f; interval = _interval; key = _key; }
public object alterRoot(IFn fn, ISeq args) { object newRoot = fn.applyTo(RT.cons(_root, args)); Validate(getValidator(), newRoot); object oldroot = _root; _root = newRoot; ++_rev; NotifyWatches(oldroot,newRoot); return newRoot; }
object Run(IFn fn) { // TODO: Define an overload called on ThreadStartDelegate or something equivalent. bool done = false; object ret = null; List <Ref> locked = new List <Ref>(); List <Notify> notify = new List <Notify>(); for (int i = 0; !done && i < RetryLimit; i++) { try { GetReadPoint(); if (i == 0) { _startPoint = _readPoint; _startTime = Environment.TickCount; } _info = new Info(RUNNING, _startPoint); ret = fn.invoke(); // make sure no one has killed us before this point, // and can't from now on if (_info.Status.compareAndSet(RUNNING, COMMITTING)) { foreach (KeyValuePair <Ref, List <CFn> > pair in _commutes) { Ref r = pair.Key; if (_sets.Contains(r)) { continue; } bool wasEnsured = _ensures.Contains(r); // can't upgrade read lock, so release ReleaseIfEnsured(r); TryWriteLock(r); locked.Add(r); if (wasEnsured && r.CurrentValPoint() > _readPoint) { throw _retryex; } Info refinfo = r.TInfo; if (refinfo != null && refinfo != _info && refinfo.IsRunning) { if (!Barge(refinfo)) { throw _retryex; } } object val = r.TryGetVal(); _vals[r] = val; foreach (CFn f in pair.Value) { _vals[r] = f.Fn.applyTo(RT.cons(_vals[r], f.Args)); } } foreach (Ref r in _sets) { TryWriteLock(r); locked.Add(r); } // validate and enqueue notifications foreach (KeyValuePair <Ref, object> pair in _vals) { Ref r = pair.Key; r.Validate(pair.Value); } // at this point, all values calced, all refs to be written locked // no more client code to be called long commitPoint = GetCommitPoint(); foreach (KeyValuePair <Ref, object> pair in _vals) { Ref r = pair.Key; object oldval = r.TryGetVal(); object newval = pair.Value; r.SetValue(newval, commitPoint); if (r.getWatches().count() > 0) { notify.Add(new Notify(r, oldval, newval)); } } done = true; _info.Status.set(COMMITTED); } } catch (RetryEx) { // eat this so we retry rather than fall out } catch (Exception ex) { if (ContainsNestedRetryEx(ex)) { // Wrapped exception, eat it. } else { throw; } } finally { for (int k = locked.Count - 1; k >= 0; --k) { locked[k].ExitWriteLock(); } locked.Clear(); foreach (Ref r in _ensures) { r.ExitReadLock(); } _ensures.Clear(); Stop(done ? COMMITTED : RETRY); try { if (done) // re-dispatch out of transaction { foreach (Notify n in notify) { n._ref.NotifyWatches(n._oldval, n._newval); } foreach (Agent.Action action in _actions) { Agent.DispatchAction(action); } } } finally { notify.Clear(); _actions.Clear(); } } } if (!done) { throw new InvalidOperationException("Transaction failed after reaching retry limit"); } return(ret); }
public void Reset() { idx = -1; predicate = null; }
public Seqer(IFn tap) { _tap = tap; }
public IRef addWatch(object key, IFn callback) { _watches = _watches.assoc(key, callback); return(this); }
public object reduce(IFn f) { if (_oa != null) { object ret = _oa[_i]; for (int x = _i + 1; x < _oa.Length; x++) ret = f.invoke(ret, _oa[x]); return ret; } object ret1 = _ilist[_i]; // JAVA 1112 wraps in RT.prepRet for (int x = _i + 1; x < _ilist.Count; x++) ret1 = f.invoke(ret1, _ilist[x]); // JAVA 1112 wraps in RT.prepRet return ret1; }
static ISeq makeSequence(IFn tap) { return(RT.seq(new LazySeq(new Seqer(tap)))); }
public object kvreduce(IFn f, object init) { int step = 0; for (int i = 0; i < _cnt; i += step) { object[] array = ArrayFor(i); for (int j = 0; j < array.Length; j++) { init = f.invoke(init, j + i, array[j]); if (RT.isReduced(init)) return ((IDeref)init).deref(); } step = array.Length; } return init; }
/// <summary> /// Construct a delay for a function. /// </summary> /// <param name="fn">The function to delay.</param> public Delay(IFn fn) { _fn = fn; _val = null; _exception = null; }
public object reduce(IFn f, object start) { int step = 0; for (int i = 0; i < _cnt; i += step) { Object[] array = ArrayFor(i); for (int j = 0; j < array.Length; ++j) { start = f.invoke(start, array[j]); if (RT.isReduced(start)) return ((IDeref)start).deref(); } step = array.Length; } return start; }
public static object ApplyToHelper(IFn fn, ISeq argList) { switch (RT.BoundedLength(argList, 20)) { case 0: argList = null; return(fn.invoke()); case 1: return(fn.invoke(Util.Ret1(argList.first(), argList = null))); case 2: return(fn.invoke(argList.first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 3: return(fn.invoke(argList.first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 4: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 5: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 6: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 7: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 8: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 9: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 10: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 11: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 12: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 13: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 14: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 15: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 16: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 17: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 18: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 19: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); case 20: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , Util.Ret1((argList = argList.next()).first(), argList = null) )); default: return(fn.invoke(argList.first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , (argList = argList.next()).first() , RT.SeqToArray <object>(Util.Ret1(argList.next(), argList = null)))); } }
public object alter(IFn fn, ISeq args) { set(fn.applyTo(RT.cons(deref(), args))); return this; }
/// <summary> /// Sets the validator. /// </summary> /// <param name="vf">The new validtor</param> public override void setValidator(IFn vf) { if (hasRoot()) Validate(vf, _root); _validator = vf; }
/// <summary> /// Send a message to the agent. /// </summary> /// <param name="fn">The function to be called on the current state and the supplied arguments.</param> /// <param name="args">The extra arguments to the function.</param> /// <param name="solo"><value>true</value> means execute on its own thread (send-off); /// <value>false</value> means use a thread pool thread (send).</param> /// <returns>This agent.</returns> public object dispatch(IFn fn, ISeq args, Boolean solo) { Exception error = getError(); if (error != null) throw new Exception("Agent is failed, needs restart", error); Action action = new Action(this,fn,args,solo); DispatchAction(action); return this; }
public IRef addWatch(Agent watcher, IFn action, bool sendOff) { _watchers = _watchers.assoc(watcher, new object[] { action, sendOff }); return this; }
public object commute(IFn fn, ISeq args) { return(LockingTransaction.GetEx().DoCommute(this, fn, args)); }
public object alter(IFn fn, ISeq args) { LockingTransaction t = LockingTransaction.GetEx(); return(t.DoSet(this, fn.applyTo(RT.cons(t.DoGet(this), args)))); }
public Task35(IFn fn) { _fn = fn; }
public Tapper(IFn xform, IFn src) { _xform = xform; _src = src; }
public object swap(IFn f, Object x, Object y, ISeq args) { for (; ; ) { object v = deref(); object newv = f.applyTo(RT.listStar(v, x, y, args)); Validate(newv); if (_state.CompareAndSet(v, newv)) { NotifyWatches(v, newv); return newv; } } }
TransformerEnumerator(IFn xform, IEnumerator sourceEnum, bool multi) { _sourceEnum = sourceEnum; _xf = (IFn)xform.invoke(new TransformHelper(o => _buffer = _buffer.Add(o))); _multi = multi; }