Esempio n. 1
0
        internal void _compose(SymbolList args, string name = null)
        {
            string[] keys   = null;
            var      kwargs = new Dictionary <string, IntPtr>();

            // Expr
            name = name;
            if (IsTrue(name))
            {
                name = CStr(name);
            }
            if (IsTrue((IsTrue((Len(args) != 0)) && IsTrue((Len(kwargs) != 0)))))
            {
                throw new TypeError("compose only accept input Symbols                 either as positional or keyword arguments, not both");
            }
            foreach (var arg in args)
            {
                if (IsTrue((!IsTrue(Isinstance(arg, typeof(SymbolBase))))))
                {
                    throw new TypeError("Compose expect `Symbol` as arguments");
                }
            }
            foreach (var val in kwargs.Values())
            {
                if (IsTrue((!IsTrue(Isinstance(val, typeof(SymbolBase))))))
                {
                    throw new TypeError("Compose expect `Symbol` as arguments");
                }
            }
            var numArgs = BinOp.Add(Len(args), Len(kwargs));

            if (IsTrue((Len(kwargs) != 0)))
            {
                keys = CoerceIntoStringArray(CStrArray(kwargs.Keys()));
                args = CHandleArray(kwargs.Values());
            }
            else
            {
                keys = CoerceIntoStringArray(null);
                args = CHandleArray(kwargs.Values());
            }
            CheckCall(_LIB.NNSymbolCompose(this.Handle, name, numArgs, keys, args));
        }
Esempio n. 2
0
 public static int Len(SymbolList list) => list.Count;