Пример #1
0
        /// <summary>
        /// Perform the specified action when the specified text view is ready
        /// </summary>
        /// <param name="textView"></param>
        /// <param name="action"></param>
        public virtual void DoActionWhenTextViewReady(FSharpFunc <Unit, Unit> action, ITextView textView)
        {
            // Local functions to do the action.
            void doAction()
            {
                // Perform action if the text view is still open.
                if (!textView.IsClosed && !textView.InLayout)
                {
                    action.Invoke(null);
                }
            }

            void doActionHandler(object sender, RoutedEventArgs e)
            {
                // Unsubscribe.
                if (sender is FrameworkElement element)
                {
                    element.Loaded -= doActionHandler;
                }

                // Then schedule the action.
                _protectedOperations.BeginInvoke(doAction, DispatcherPriority.Loaded);
            }

            if (textView is IWpfTextView wpfTextView && !wpfTextView.VisualElement.IsLoaded)
            {
                // FrameworkElement.Loaded Event:
                //
                // Occurs when a FrameworkElement has been constructed and
                // added to the object tree, and is ready for interaction.
                wpfTextView.VisualElement.Loaded += doActionHandler;
            }
Пример #2
0
            public static Deedle.Series <a, b> ofObservations <a, b>(IEnumerable <Tuple <a, b> > observations)
            {
                Tuple <a, b>[] tupleArray1 = (Tuple <a, b>[])ArrayModule.OfSeq <Tuple <a, b> >((IEnumerable <M0>)observations);
                FSharpFunc <Tuple <a, b>, a> fsharpFunc1 = (FSharpFunc <Tuple <a, b>, a>) new FSeriesextensions.ofObservations <a, b>();

                Tuple <a, b>[] tupleArray2 = tupleArray1;
                if ((object)tupleArray2 == null)
                {
                    throw new ArgumentNullException("array");
                }
                a[] aArray1 = new a[tupleArray2.Length];
                for (int index = 0; index < aArray1.Length; ++index)
                {
                    aArray1[index] = fsharpFunc1.Invoke(tupleArray2[index]);
                }
                a[] aArray2 = aArray1;
                FSharpFunc <Tuple <a, b>, b> fsharpFunc2 = (FSharpFunc <Tuple <a, b>, b>) new FSeriesextensions.ofObservations <a, b>();

                Tuple <a, b>[] tupleArray3 = tupleArray1;
                if ((object)tupleArray3 == null)
                {
                    throw new ArgumentNullException("array");
                }
                b[] values = new b[tupleArray3.Length];
                a[] keys   = aArray2;
                for (int index = 0; index < values.Length; ++index)
                {
                    values[index] = fsharpFunc2.Invoke(tupleArray3[index]);
                }
                return(new Deedle.Series <a, b>(keys, values));
            }
Пример #3
0
        public static Frame <TRowKey, TColumnKey> GetRowsAt <TRowKey, TColumnKey>(this Frame <TRowKey, TColumnKey> frame, params int[] indices)
        {
            int[] numArray1 = indices;
            FSharpFunc <int, TRowKey> fsharpFunc1 = (FSharpFunc <int, TRowKey>) new FrameExtensions.keys9 <TRowKey, TColumnKey>(frame.Rows);

            int[] numArray2 = numArray1;
            if ((object)numArray2 == null)
            {
                throw new ArgumentNullException("array");
            }
            TRowKey[] rowKeyArray1 = new TRowKey[numArray2.Length];
            for (int index = 0; index < rowKeyArray1.Length; ++index)
            {
                rowKeyArray1[index] = fsharpFunc1.Invoke(numArray2[index]);
            }
            TRowKey[] rowKeyArray2 = rowKeyArray1;
            int[]     numArray3    = indices;
            FSharpFunc <int, ISeries <TColumnKey> > fsharpFunc2 = (FSharpFunc <int, ISeries <TColumnKey> >) new FrameExtensions.values0 <TColumnKey, TRowKey>(frame);

            int[] numArray4 = numArray3;
            if ((object)numArray4 == null)
            {
                throw new ArgumentNullException("array");
            }
            ISeries <TColumnKey>[] seriesArray1 = new ISeries <TColumnKey> [numArray4.Length];
            for (int index = 0; index < seriesArray1.Length; ++index)
            {
                seriesArray1[index] = fsharpFunc2.Invoke(numArray4[index]);
            }
            ISeries <TColumnKey>[] seriesArray2 = seriesArray1;
            return(FFrameextensions.FrameofRowsStatic <TRowKey, ISeries <TColumnKey>, TColumnKey>((IEnumerable <Tuple <TRowKey, ISeries <TColumnKey> > >)SeqModule.Zip <TRowKey, ISeries <TColumnKey> >((IEnumerable <M0>)rowKeyArray2, (IEnumerable <M1>)seriesArray2)));
        }
Пример #4
0
        public static double Mean <K, V>(this Series <K, V> series)
        {
            Series <K, V> series1 = series;
            int           num1    = 1;

            OptionalValue <V>[] optionalValueArray = StatsInternal.valuesAllOpt <K, V>(series1);
            int num2 = num1;

            V[] vArray1 = ArrayModule.Choose <OptionalValue <V>, V>((FSharpFunc <M0, FSharpOption <M1> >) new SeriesStatsExtensions.Mean <V>(), (M0[])optionalValueArray);
            FSharpFunc <V, double> fsharpFunc = (FSharpFunc <V, double>) new SeriesStatsExtensions.Mean <V>();

            V[] vArray2 = vArray1;
            if ((object)vArray2 == null)
            {
                throw new ArgumentNullException("array");
            }
            double[] init   = new double[vArray2.Length];
            int      moment = num2;

            for (int index = 0; index < init.Length; ++index)
            {
                init[index] = fsharpFunc.Invoke(vArray2[index]);
            }
            StatsInternal.Sums sums = StatsInternal.initSumsDense(moment, init);
            return(sums.sum / sums.nobs);
        }
Пример #5
0
        public static double Median <K, V>(this Series <K, V> series)
        {
            V[] vArray1 = (V[])ArrayModule.OfSeq <V>((IEnumerable <M0>)series.Values);
            FSharpFunc <V, double> fsharpFunc = (FSharpFunc <V, double>) new SeriesStatsExtensions.Median <V>();

            V[] vArray2 = vArray1;
            if ((object)vArray2 == null)
            {
                throw new ArgumentNullException("array");
            }
            double[] numArray = new double[vArray2.Length];
            for (int index = 0; index < numArray.Length; ++index)
            {
                numArray[index] = fsharpFunc.Invoke(vArray2[index]);
            }
            double[] arr = numArray;
            int      n   = arr.Length / 2;

            if (arr.Length == 0)
            {
                return(Operators.get_NaN());
            }
            if (arr.Length % 2 == 1)
            {
                return(StatsInternal.quickSelectInplace(n, arr));
            }
            return((StatsInternal.quickSelectInplace(n, arr) + StatsInternal.quickSelectInplace(n - 1, arr)) / 2.0);
        }
Пример #6
0
 public void DoActionWhenTextViewReady(FSharpFunc <Unit, Unit> action, ITextView textView)
 {
     // Perform action if the text view is still open.
     if (!textView.IsClosed && !textView.InLayout)
     {
         action.Invoke(null);
     }
 }
Пример #7
0
        public IPipeline <TInput, TMapped> Then <TMapped>(FSharpFunc <TOutput, TMapped> nextfunction)
        {
            var compose =
                FSharpFuncUtils.Create <TInput, TMapped>(value =>
                                                         nextfunction.Invoke(_function.Invoke(value)));

            return(new CsPipeline <TInput, TMapped>(compose));
        }
Пример #8
0
        public void FromAction()
        {
            int a = 0;
            FSharpFunc <Unit, Unit> ff = FSharpFunc.FromAction(() => a = 1);

            ff.Invoke(null);
            Assert.AreEqual(1, a);
        }
 void IRunner.OnShrink
   ( FSharpList<object> args
   , FSharpFunc<FSharpList<object>, string> everyShrink
   )
 {   var msg = everyShrink.Invoke(args);
     if (!silent)
     {   Console.Write(msg);
     }
 }
Пример #10
0
        ChainStatus Optimizations.IHeadStart <T> .Execute(ReadOnlySpan <T> source)
        {
            var status = ChainStatus.Flow;

            foreach (var input in source)
            {
                var maybe = chooser.Invoke(input);
                if (maybe.IsSome)
                {
                    status = Next(maybe.Item);
                    if (status.IsStopped())
                    {
                        break;
                    }
                }
            }
            return(status);
        }
 void IRunner.OnArguments
   ( int ntest
   , FSharpList<object> args
   , FSharpFunc<int, FSharpFunc<FSharpList<object>, string>> every
   )
 {   var msg = every.Invoke(ntest).Invoke(args);
     if (!silent)
     {   Console.Write(msg);
     }
 }
Пример #12
0
        public OptionalValue <Series <K, R> > TryAs <R>(ConversionKind conversionKind)
        {
            OptionalValue <IVector <R> >             optionalValue1 = VectorHelpers.tryConvertType <R>(conversionKind, (IVector)this.vector);
            FSharpFunc <IVector <R>, Series <K, R> > fsharpFunc     = (FSharpFunc <IVector <R>, Series <K, R> >) new \u0024Series.TryAs\u00401255 <K, R> (this);
            OptionalValue <IVector <R> >             optionalValue2 = optionalValue1;

            if (optionalValue2.HasValue)
            {
                return(new OptionalValue <Series <K, R> >(fsharpFunc.Invoke(optionalValue2.Value)));
            }
            return(OptionalValue <Series <K, R> > .Missing);
        }
Пример #13
0
        public OptionalValue <R> TryGetAs <R>(K column)
        {
            OptionalValue <object> optionalValue1 = this.TryGet(column);
            FSharpFunc <object, R> fsharpFunc     = (FSharpFunc <object, R>) new \u0024Series.TryGetAs\u00401245 <R> ();
            OptionalValue <object> optionalValue2 = optionalValue1;

            if (optionalValue2.HasValue)
            {
                return(new OptionalValue <R>(fsharpFunc.Invoke(optionalValue2.Value)));
            }
            return(OptionalValue <R> .Missing);
        }
Пример #14
0
        private void TestButtonClick(object sender, RoutedEventArgs e)
        {
            viewCanvas.Children.Clear();

            var singleDim = TransformDrawnImageToStandartView();

            DrawArray(singleDim);
            var predictedValue = predictor.Invoke(MatrixModule.ofList(NN.makeList(singleDim)));

            prediction.Content = string.Format("Prediction is {0}", predictedValue);
            iter++;
            drawingCanvas.Children.Clear();
        }
Пример #15
0
 void IVimHost.DoActionWhenTextViewReady(FSharpFunc <Unit, Unit> action, ITextView textView)
 {
     if (DoActionWhenTextViewReadyFunc != null)
     {
         DoActionWhenTextViewReadyFunc(action, textView);
     }
     else
     {
         // Simulate the conditions that would be true if
         // wpfTextView.IsLoaded were true using textView.
         if (!textView.IsClosed && !textView.InLayout && textView.TextViewLines != null)
         {
             action.Invoke(null);
         }
     }
 }
Пример #16
0
        public override Reply <string> Invoke(CharStream <TUserState> stream)
        {
            var reply = CharParser1.Invoke(stream);

            if (reply.Status == ReplyStatus.Ok)
            {
                return(ParseRestOfString(stream, reply.Result, reply.Error));
            }
            else
            {
                return new Reply <string> {
                           Status = reply.Status, Error = reply.Error
                }
            };
        }

#if !LOW_TRUST
        unsafe
Пример #17
0
        public void FindInFiles(string pattern, bool matchCase, string filesOfType, VimGrepFlags flags, FSharpFunc <Unit, Unit> action)
        {
            var find = new FindReplace();

            var options = new FilterOptions
            {
                CaseSensitive = matchCase,
                RegexSearch   = true,
            };
            var scope = new ShellWildcardSearchScope(_vim.VimData.CurrentDirectory, filesOfType);

            using (var monitor = IdeApp.Workbench.ProgressMonitors.GetSearchProgressMonitor(true))
            {
                var results = find.FindAll(scope, monitor, pattern, null, options, System.Threading.CancellationToken.None);
                foreach (var result in results)
                {
                    //TODO: Cancellation?
                    monitor.ReportResult(result);
                }
            }

            action.Invoke(null);
        }
Пример #18
0
        public Size Relayout(RectangleF bounds)
        {
            if (_document != null && _document.Body != null)
            {
                if (_document.ReadyState != "complete")
                {
                    return(Size.Empty);
                }

                if (_isDocumentDirty || _layout == null)
                {
                    _lfun = OptimusLayout.Layout(new Layout.LayoutSettings(true, FSharpMeasureString), _document.Body);
                }

                if (_isDocumentDirty || _lastBounds != bounds || _layout == null)
                {
                    _layout          = _lfun.Invoke((int)bounds.Right).ToList();
                    _lastBounds      = bounds;
                    _isDocumentDirty = false;
                }
            }

            return(GetSize());
        }
Пример #19
0
 static public int ExtendFSharpFuncIntIntNoArg(this FSharpFunc <int, int> s1)
 {
     return(s1.Invoke(3));
 }
Пример #20
0
        private T Calculate(DateTime epoch, int recurse, ISession session = null, bool retry = true)
        {
            if (recurse > 60)
            {
                throw new LockRecursionException();
            }
            bool taken  = false;
            bool pushed = false;

            try
            {
                _spinLock.Enter(ref taken);
                if (taken)
                {
                    if (_state == (int)CellState.Clean && session == null || (_epoch > epoch && session == null))
                    {
                        return(_value);      // don't recalculate for read
                    }
                    SetState(CellState.Calculating);
                    _spinLock.Exit(true);
                    taken = false;
                    if (_link)
                    {
                        Cell.Current.Value.Push(this);
                        pushed = true;
                    }

                    var t = (_func != null ? _func.Invoke(null) : _value);
                    if (session != null)
                    {
                        session.SetValue <T>(this, t);
                    }

                    while (taken == false)
                    {
                        // sleep through massive contention
                        _spinLock.Enter(ref taken);
                        if (!taken)
                        {
                            Thread.Sleep(recurse++ *100);
                            return(Calculate(epoch, recurse, session));
                        }
                    }
                    if (epoch >= _epoch)
                    {
                        _epoch = epoch;
                        _value = t;
                    }
                    SetState(CellState.Clean);
                    if (_pending > 0)
                    {
                        if (session != null)
                        {
                            _pending--;
                        }
                    }
                    if (pushed)
                    {
                        Cell.Current.Value.Pop();
                        _link  = false;
                        pushed = false;
                    }
                    if (_isBool && _flip && (Convert.ToBoolean(t) != Convert.ToBoolean(_value)))
                    {
                        _flip = false;
                        RaiseChange(CellEvent.Link, this, this, _epoch, session);
                    }
                    return(LinkReturn(t));
                }
                else
                {
                    Thread.Sleep(recurse * 100);
                    return(Calculate(epoch, recurse + 1, session));     // edge case retry lock
                }
            }
            catch (Exception e)
            {
                if (retry)
                {
                    if (taken)
                    {
                        _spinLock.Exit(true);
                    }
                    Thread.Sleep(0);
                    return(Calculate(epoch, recurse + 1, session, false));
                }
                else
                {
                    _lastException = e;
                    SetState(CellState.Error);
                    RaiseChange(CellEvent.Error, this, this, epoch, null);

                    throw;
                }
            }
            finally
            {
                if (pushed)
                {
                    Cell.Current.Value.Pop();
                    _link = false;
                }
                if (taken)
                {
                    _spinLock.Exit(true);
                }
            }
        }
Пример #21
0
 private void connect()
 {
     string host = textBox1.Text.Substring(0,textBox1.Text.IndexOf(':'));
     string port = textBox1.Text.Substring(host.Length + 1);
     var fsharp_func = Microsoft.FSharp.Core.FSharpFunc<string, object>.FromConverter(
                new Converter<string, object>(AfterReceivingFunction));
     writer =
        fsmsclient.library.initconnectionCS(fsmsclient.library.initConnection,
        host,
        Convert.ToInt32(port), fsharp_func);
     writer.Invoke("0\n\n");
     textBox1.Text = "Connected";
 }
Пример #22
0
 static public U ExtendFSharpFuncGenericOneArg <T, U>(this FSharpFunc <T, U> s1, T arg)
 {
     return(s1.Invoke(arg));
 }
Пример #23
0
 public static TResult Invoke <TResult>(this FSharpFunc <Unit, TResult> func)
 {
     return(func.Invoke(null));
 }
Пример #24
0
        public static Frame <int, int> FromArray2D <T>(T[,] array)
        {
            IIndexBuilder         instance1   = FIndexBuilderimplementation.IndexBuilder.Instance;
            int                   length1     = array.GetLength(0);
            FSharpFunc <int, int> fsharpFunc1 = (FSharpFunc <int, int>) new FrameExtensions.rowIndex();

            if (length1 < 0)
            {
                throw new ArgumentException(string.Format("{0}\n{1} = {2}", new object[3]
                {
                    (object)LanguagePrimitives.ErrorStrings.get_InputMustBeNonNegativeString(),
                    (object)"count",
                    (object)length1
                }), "count");
            }
            int[]         numArray1     = new int[length1];
            IIndexBuilder indexBuilder1 = instance1;

            for (int index = 0; index < numArray1.Length; ++index)
            {
                numArray1[index] = fsharpFunc1.Invoke(index);
            }
            IIndex <int>          rowIndex    = indexBuilder1.Create <int>((IEnumerable <int>)numArray1, FSharpOption <bool> .Some(true));
            IIndexBuilder         instance2   = FIndexBuilderimplementation.IndexBuilder.Instance;
            int                   length2     = array.GetLength(1);
            FSharpFunc <int, int> fsharpFunc2 = (FSharpFunc <int, int>) new FrameExtensions.colIndex();

            if (length2 < 0)
            {
                throw new ArgumentException(string.Format("{0}\n{1} = {2}", new object[3]
                {
                    (object)LanguagePrimitives.ErrorStrings.get_InputMustBeNonNegativeString(),
                    (object)"count",
                    (object)length2
                }), "count");
            }
            int[]         numArray2     = new int[length2];
            IIndexBuilder indexBuilder2 = instance2;

            for (int index = 0; index < numArray2.Length; ++index)
            {
                numArray2[index] = fsharpFunc2.Invoke(index);
            }
            IIndex <int> columnIndex = indexBuilder2.Create <int>((IEnumerable <int>)numArray2, FSharpOption <bool> .Some(true));

            IVector[] vectorArray = (IVector[])ArrayModule.ZeroCreate <IVector>(array.GetLength(1));
            for (int c = 0; c < vectorArray.Length; ++c)
            {
                int length3 = array.GetLength(0);
                FSharpFunc <int, T> fsharpFunc3 = (FSharpFunc <int, T>) new FrameExtensions.col <T>(array, c);
                if (length3 < 0)
                {
                    throw new ArgumentException(string.Format("{0}\n{1} = {2}", new object[3]
                    {
                        (object)LanguagePrimitives.ErrorStrings.get_InputMustBeNonNegativeString(),
                        (object)"count",
                        (object)length3
                    }), "count");
                }
                T[] objArray1 = new T[length3];
                for (int index = 0; index < objArray1.Length; ++index)
                {
                    objArray1[index] = fsharpFunc3.Invoke(index);
                }
                T[] objArray2 = objArray1;
                vectorArray[c] = (IVector)FVectorBuilderimplementation.VectorBuilder.Instance.Create <T>(objArray2);
            }
            IVector <IVector> data = FVectorBuilderimplementation.VectorBuilder.Instance.Create <IVector>(vectorArray);

            return(new Frame <int, int>(rowIndex, columnIndex, data, FIndexBuilderimplementation.IndexBuilder.Instance, FVectorBuilderimplementation.VectorBuilder.Instance));
        }
Пример #25
0
     protected Reply <string> ParseRestOfString(CharStream <TUserState> stream, char firstChar, ErrorMessageList error)
     {
 #if LOW_TRUST
         var sb = new StringBuilder(16);
         sb.Append(firstChar);
 #else
         _16CharBuffer buffer_; // produces more efficient code on .NET than stackalloc char[16]
         char *        buffer = (char *)(&buffer_);
         buffer[0] = firstChar;
         char[] chars = null;
         uint   n     = 1;
 #endif
         for (;;)
         {
             var tag   = stream.StateTag;
             var reply = CharParser.Invoke(stream);
             if (reply.Status == ReplyStatus.Ok)
             {
                 if (tag == stream.StateTag)
                 {
                     throw Internal.ParserCombinatorInInfiniteLoopHelper.CreateException("manyChars", stream);
                 }
                 error = reply.Error;
         #if LOW_TRUST
                 sb.Append(reply.Result);
         #else
                 var i = n % 16;
                 if (i != 0)
                 {
                     buffer[i] = reply.Result;
                     ++n;
                 }
                 else
                 {
                     if (chars == null)
                     {
                         chars = new char[32];
                     }
                     else if (n == chars.Length)
                     {
                         var newChars = new char[2 * chars.Length];
                         Array.Copy(chars, newChars, chars.Length);
                         chars = newChars;
                     }
                     for (i = 0; i < 16; ++i)
                     {
                         chars[n - 16 + i] = buffer[i];
                     }
                     buffer[0] = reply.Result;
                     ++n;
                 }
         #endif
             }
             else if (reply.Status == ReplyStatus.Error && tag == stream.StateTag)
             {
                 string str;
         #if LOW_TRUST
                 str = sb.ToString();
         #else
                 if (n <= 16)
                 {
                     str = new String(buffer, 0, (int)n);
                 }
                 else
                 {
                     for (uint i = (n - 1) & 0x7ffffff0u; i < n; ++i)
                     {
                         chars[i] = buffer[i % 16];
                     }
                     str = new string(chars, 0, (int)n);
                 }
         #endif
                 error = ErrorMessageList.Merge(error, reply.Error);
                 return(new Reply <string> {
                     Status = ReplyStatus.Ok, Result = str, Error = error
                 });
             }
             else
             {
                 error = tag == stream.StateTag ? ErrorMessageList.Merge(error, reply.Error) : reply.Error;
                 return(new Reply <string> {
                     Status = reply.Status, Error = error
                 });
             }
         }
     }
Пример #26
0
        private T Calculate(DateTime epoch, int recurse, ISession session = null, bool retry = true)
        {
            if (recurse > 60)
            {
                throw new LockRecursionException();
            }
            bool taken = false;

            try
            {
                _spinLock.Enter(ref taken);
                if (taken)
                {
                    if (_state == (int)CellState.Clean && session == null)
                    {
                        return(_value);      // don't recalculate for read
                    }
                    SetState(CellState.Calculating);
                    _spinLock.Exit(true);
                    taken = false;

                    var t = (_func != null ? _func.Invoke(null) : _value);

                    if (session != null)
                    {
                        session.SetValue <T>(this, t);
                    }

                    while (taken == false)
                    {
                        // sleep through massive contention
                        _spinLock.Enter(ref taken);
                        if (!taken)
                        {
                            Thread.Sleep(recurse++ *100);
                            return(Calculate(epoch, recurse, session));
                        }
                    }
                    if (epoch > _epoch)
                    {
                        _epoch = epoch;
                        _value = t;
                    }
                    SetState(CellState.Clean);
                    if (_pending > 0)
                    {
                        if (session != null)
                        {
                            _pending--;
                        }
                    }
                    return(t);
                }
                else
                {
                    Thread.Sleep(recurse * 100);
                    return(Calculate(epoch, recurse + 1, session));     // edge case retry lock
                }
            }
            catch (Exception e)
            {
                if (retry)
                {
                    if (taken)
                    {
                        _spinLock.Exit(true);
                    }
                    Thread.Sleep(0);
                    return(Calculate(epoch, recurse + 1, session, false));
                }
                else
                {
                    _lastException = e;
                    SetState(CellState.Error);
                    RaiseChange(CellEvent.Error, this, epoch, null);
                    throw;
                }
            }
            finally
            {
                if (taken)
                {
                    _spinLock.Exit(true);
                }
            }
        }
Пример #27
0
 /// <summary>Applies the parser `p` to the input string.</summary>
 public static Reply <TResult> ParseString <TResult>(
     this FSharpFunc <CharStream <Unit>, Reply <TResult> > p,
     string chars)
 => p.Invoke(new CharStream <Unit>(chars, 0, chars.Length));
Пример #28
0
 public void DoActionWhenTextViewReady(FSharpFunc <Unit, Unit> action, ITextView textView)
 {
     action.Invoke(null);
 }
Пример #29
0
 /// <summary>
 /// <para>Applies the parser `p` to the input file.</para>
 /// <para>
 /// In case no unicode byte order mark is found, the file data is assumed to be encoded
 /// with the given `encoding`. `Encoding.Default` will be used if `encoding` was not
 /// specified.
 /// </para>
 /// </summary>
 public static Reply <TResult> ParseFile <TResult>(
     this FSharpFunc <CharStream <Unit>, Reply <TResult> > p,
     string path,
     Encoding?encoding = null)
 => p.Invoke(new CharStream <Unit>(path, encoding ?? Encoding.Default, detectEncodingFromByteOrderMarks: true));
Пример #30
0
 /// <summary>Applies the parser `p` to the input `CharStream`.</summary>
 public static Reply <TResult> Parse <TResult>(
     this FSharpFunc <CharStream <Unit>, Reply <TResult> > p,
     CharStream <Unit> chars)
 => p.Invoke(chars);
Пример #31
0
 public override TTerm Invoke(TAfterString afterString, TTerm term)
 {
     return(Mapping.Invoke(term));
 }
Пример #32
0
 public void OnNext(Tuple <ISession, Generic.ICell <T>, CellEvent, ICell, DateTime> value)
 {
     Log.Verbose("Session {0} Cell {1} Value {2} Event {3} Source {4} Epoch {5}", value.Item1, value.Item2.Mnemonic, _formater.Invoke(value.Item2.Value), value.Item3, value.Item4, value.Item5);
 }
Пример #33
0
 /// <summary>
 ///  Example of a higher order function
 /// </summary>
 public static FinalGameScore MapScore(FSharpFunc<int, int> f, FinalGameScore game)
 {
     return new FinalGameScore(game.Game, f.Invoke(game.FinalScore));
 }