Ejemplo n.º 1
0
        /// <summary>
        /// AArray generated by type and shape with Reshape dyadic nonscalar function.
        /// If shape list is null, we give back the filler elemenet.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="shape"></param>
        internal static AType FillElement(ATypes type, AType shape = null)
        {
            AType filler = null;

            switch (type)
            {
            case ATypes.ABox:
            case ATypes.AFunc:
                filler = ABox.Create(ANull());
                break;

            case ATypes.AChar:
                filler = AChar.Create(' ');
                break;

            case ATypes.AFloat:
                filler = AFloat.Create(0);
                break;

            case ATypes.AInteger:
                filler = AInteger.Create(0);
                break;

            case ATypes.ASymbol:
                filler = ASymbol.Create("");
                break;

            default:
                throw new NotImplementedException("Invalid use-case");
            }

            if (shape != null)
            {
                return(AplusCore.Runtime.Function.Dyadic.DyadicFunctionInstance.Reshape.Execute(filler, shape));
            }
            else
            {
                return(filler);
            }
        }