Ejemplo n.º 1
0
 public Tuple <T1, T2> Pack <T1, T2>(T1 a, T2 b)
 {
     return(_compact.Pack(a, b));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a memoized version of the passed function
        /// </summary>
        /// <typeparam name="TArg1">The type of the first argument of the passed function</typeparam>
        /// <typeparam name="TArg2">The type of the second argument of the passed function</typeparam>
        /// <typeparam name="TResult">The type of the result of the passed function</typeparam>
        /// <param name="function">The function to memoize</param>
        /// <returns>A memoized version of the passed function</returns>
        public Func <TArg1, TArg2, TResult> Memoize <TArg1, TArg2, TResult>(Func <TArg1, TArg2, TResult> function)
        {
            var localStore   = new Dictionary <Tuple <TArg1, TArg2>, TResult>();
            var fn           = function;
            var packedTarget = Memoize(_fnCompactor.Pack(function));

            return((a, b) => packedTarget(_paramCompactor.Pack(a, b)));
        }