整装待发,Numahk开启ahk人工智能学习之路(将翻新,该库不再维护)

写在最前

不再维护,新的真正的Numahk库即将发布

终于还是把Sinet库最核心的东西提取了出来,Numahk库(Sinet库里叫Numpy),这个库依赖关系相对比较复杂,我陆陆续续会把解析贴在这个版面,现在先把整体代码贴出来。这个库的使用完全对等Python的Numpy,只是函数相对不够完善。具体使用后续会添加,迫切想知道怎么用的可以去看我的Sinet库更新日志。

***项目预告,我后续会就人工智能的机器学习模块开展一个项目(也不知道可以做到什么程度),这个库是完成这个项目的核心之一。

更新时间:2022.8.5 修复若干问题,引入依赖库。

Numahk食用说明

1.使用前建议了解一下Python的Numpy库,这个的基础思路就是建立在Numpy之上。

2.对于四则运算有八个特殊函数,使用时也会有一些注意事项。这里建议看Sinet库的更新日志,有较为详尽的介绍。

完整代码及注意事项

***注意:ntladd中的地址是你的ntl.dll的地址,Numahk库需要依赖较为精确的计算,因此将NTLCalc引入。

***注意:这个完整代码里包含了List类,因此请不要将Sinet库的List篇里的代码和这个贴在一起。

ntladd := "C:\Users\HP\Desktop\AI\Supervised Learning\ntl.dll"

Class Numahk
{
    Static Abs(NDArray)
    {
        New_Pos := []
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] := Abs(NDArray[i*])
        
        Return NDArray
    }
    
    Static Add(NDArray, Number := 0)
    {
        New_Pos := []
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] += Number
        
        Return NDArray
    }
    
    Static Arange(Num*)
    {
        if Num.Length == 1
            New_NDArray := Range(0, Num[1])
        
        else if Num.Length == 2
            New_NDArray := Range(Num[1], Num[2])
            
        else
            New_NDArray := Range(Num[1], Num[2], Num[3])
        
        Return Numahk.array(New_NDArray)
    }
    
    Static Argmax(NDArray, Axis := "axis=-1")
    {
        if Instr(Axis, "=")
            Axis := Trim(StrSplit(Axis, "=")[2])
        
        if Axis == -1
            Axis := NDArray.ndim - 1
        
        if NDArray.ndim == 1
        {
            max_index := 0
            max_num := NDArray.array[0]
            
            For i in NDArray.array
            {
                if i > max_num
                {
                    max_num := i
                    max_index := A_Index - 1
                }
            }
            
            Return max_index
        }
        
        else
        {
            Lst_Res := List()
            Lst_Pos := List()
            
            Loop NDArray.ndim
            {
                if Axis == A_Index - 1
                    Lst_Pos.Append([":"])
                
                else
                    Lst_Pos.Append(Range(NDArray.Shape[A_Index - 1]))
            }
            
            Lst_Pos := Dynloop_Loop(Lst_Pos)
            
            For i in Lst_Pos
                Lst_Res.Append(Numahk.ArgMax(Numahk.array(NDArray[i*])))
            
            Lst_Res := Numahk.array(Lst_Res)
            NDArray.shape.RemoveAt(Axis + 1)
            Lst_Res.reshape(NDArray.shape*)
            
            Return Numahk.ToList(Lst_Res)
        }
    }
    
    Static ArgSort(Lst, Axis := "axis=-1")
    {
        if Type(Lst) !== "Numahk.NDArray"
            New_NDArray := Numahk.array(Lst)
        
        else
            New_NDArray := Lst.Copy()
        
        if Instr(Axis, "=")
            Axis := Trim(StrSplit(Axis, "=")[2])
        
        if Axis == -1
            Axis := New_NDArray.ndim - 1
        
        if New_NDArray.ndim == 1
            Return Numahk.ToList(Numahk.DulSort(New_NDArray, Range(New_NDArray.array.Length)))
        
        else
        {
            Lst_Res := List()
            Lst_Pos := List()
            
            Loop New_NDArray.ndim
            {
                if Axis == A_Index - 1
                    Lst_Pos.Append([":"])
                
                else
                    Lst_Pos.Append(Range(New_NDArray.Shape[A_Index - 1]))
            }
            
            Lst_Pos := Dynloop_Loop(Lst_Pos)
            
            For i in Lst_Pos
                Lst_Res.Append(Numahk.ToList(Numahk.DulSort(New_NDArray[i*], Range(New_NDArray[i*].Length))))
            
            Lst_Res := Numahk.array(Lst_Res)
            New_NDArray.shape.RemoveAt(Axis + 1)
            Lst_Res.reshape(New_NDArray.shape*)
            
            if Axis !== New_NDArray.ndim - 1
                Lst_Res.Transpose()
            
            Return Numahk.ToList(Lst_Res)
        }
    }
    
    Static Array(Lst)
    {
        Return Numahk.NDArray(Lst)
    }
    
    Static C_(NDArray*)
    {
        Lst_Res := List()
        
        For i in NDArray
        {
            if Type(i) == "String"
                NDArray[A_Index] := List(List(StrSplit(i, "")*))
            
            else if ListIn(["Integer", "Float"], Type(i)) !== "Not Found"
                NDArray[A_Index] := List(List(i))
            
            else if Type(i) == "Numahk.NDArray"
                NDArray[A_Index] := Numahk.tolist(i)
        }
        
        Loop NDArray[1].Length
        {
            Temp := List()
            index := A_Index - 1
            
            Loop NDArray.Length
                Temp.Extend(NDArray[A_Index][index])
            
            Lst_Res.Append(Temp)
        }
        
        Return Lst_Res
    }
    
    Static Cmp(NDArray1, NDArray2)
    {
        Lst_Pos := NDArray1.shape.Clone()
        Lst_Res := Numahk.Zeros_Like(NDArray1)
        
        For i in Lst_Pos
            Lst_Pos[A_Index - 1] := Range(i)
        
        Lst_Pos := Dynloop_Loop(Lst_Pos)
        
        For i in Lst_Pos
        {
            if NDArray1[i*] == NDArray2[i*]
                Lst_Res[i*] := 1
        }
        
        Return Lst_Res
    }
    
    Static Div(NDArray, Number := 1)
    {
        New_Pos := []
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] /= Number
        
        Return NDArray
    }
    
    Static Divide(NDArray*)
    {
        New_Pos := []
        
        For i in NDArray[1].shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
        {
            Loop NDArray.Length - 1
                NDArray[1][i*] /= NDArray[A_Index + 1][i*]
        }
        
        Return NDArray[1]
    }
    
    Static Dot(NDArray*)
    {
        Temp := NDArray.RemoveAt(1).Copy()
        
        if !NDArray.Length
            Return Temp
        
        if NDArray.Length == 1
        {
            Temp2 := NDArray.RemoveAt(1).Copy()
            Temp3 := Numahk.Zeros(List(Temp.Shape[0], Temp2.Shape[1]))
            
            For i in xrange(Temp.Shape[0])
            {
                For j in xrange(Temp2.Shape[1])
                {
                    Sum := 0
                    
                    For k in xrange(Temp.Shape[1])
                        Sum += Temp[i, k] * Temp2[k, j]
                    
                    Temp3[i, j] := Round(Sum, 10)
                }
            }
            
            Return Temp3
        }
        
        else
        {
            Temp2 := Numahk.Dot(Temp, NDArray.RemoveAt(1).Copy())
            Return Numahk.Dot(Temp2, NDArray*)
        }
    }
    
    Static DulSort(NDArray, CNDArray)
    {
        if Type(NDArray) !== "Numahk.NDArray"
            NDArray := Numahk.array(NDArray)
        
        if Type(CNDArray) !== "Numahk.NDArray"
            CNDArray := Numahk.array(CNDArray)
        
        For i in XRange(NDArray.array.Length)
        {
            For j in XRange(i + 1, NDArray.array.Length)
            {
                if NDArray[i] > NDArray[j]
                {
                    Temp := NDArray[i]
                    NDArray[i] := NDArray[j]
                    NDArray[j] := Temp
                    
                    Temp := CNDArray[i]
                    CNDArray[i] := CNDArray[j]
                    CNDArray[j] := Temp
                }
            }
        }
        
        Return CNDArray
    }
    
    Static Empty(Shape)
    {
        Return Numahk.Zeros(Shape)
    }
    
    Static Equal(NDArray1, NDArray2)
    {
        New_Pos := []
        NDArray := Numahk.Zeros(NDArray1.Shape)
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] := (NDArray1[i*] == NDArray2[i*])
        
        Return NDArray
    }
    
    Static Exp(NDArray)
    {
        New_Pos := []
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] := Math.Exp(NDArray[i*])
        
        Return NDArray
    }
    
    Static Flip(NDArray, Axis := -1)
    {
        
    }
    
    Static Greater(NDArray1, NDArray2)
    {
        New_Pos := []
        NDArray := Numahk.Zeros(NDArray1.Shape)
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] := (NDArray1[i*] > NDArray2[i*])
        
        Return NDArray
    }
    
    Static Greater_Equal(NDArray1, NDArray2)
    {
        New_Pos := []
        NDArray := Numahk.Zeros(NDArray1.Shape)
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] := (NDArray1[i*] >= NDArray2[i*])
        
        Return NDArray
    }
    
    Static Less(NDArray1, NDArray2)
    {
        New_Pos := []
        NDArray := Numahk.Zeros(NDArray1.Shape)
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] := (NDArray1[i*] < NDArray2[i*])
        
        Return NDArray
    }
    
    Static Less_Equal(NDArray1, NDArray2)
    {
        New_Pos := []
        NDArray := Numahk.Zeros(NDArray1.Shape)
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] := (NDArray1[i*] <= NDArray2[i*])
        
        Return NDArray
    }
    
    Static Linspace(Stop, Start := 0, Num := 1, Endpoint := True, Swap := -1)
    {
        if Start && Swap == -1
        {
            Temp := Stop
            Stop := Start
            Start := Temp
        }
        
        if Endpoint
            Num -= 1
        
        Step := (Stop - Start) / Num
        
        if Endpoint
            Stop += Step
        
        Return Numahk.array(Range(Start, Stop, Step))
    }
    
    Static Linspaces(Param*)
    {
        Temp :=
        {
            Start : 0,
            Stop : 1,
            Num : 11,
            Endpoint : True
        }
        
        For i in Param
        {
            Lst_i := StrSplit(i, "=")
            
            if ListIn(Temp, StrTitle(Trim(Lst_i[1]))) !== "Not Found"
            {
                if StrTitle(Trim(Lst_i[2])) == "False"
                    Lst_i[2] := False
                
                else if StrTitle(Trim(Lst_i[2])) == "True"
                    Lst_i[2] := True
                
                Temp.%StrTitle(Trim(Lst_i[1]))% := Trim(Lst_i[2])
            }
        }
        
        if Temp.Endpoint
            Temp.Num -= 1
        
        Step := (Temp.Stop - Temp.Start) / Temp.Num
        
        if Temp.Endpoint
            Temp.Stop += Step
        
        Return Numahk.array(Range(Temp.Start, Temp.Stop, Step))
    }
    
    Static Log(NDArray)
    {
        New_Pos := []
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] := Math.Log(NDArray[i*])
        
        Return NDArray
    }
    
    Static Log10(NDArray)
    {
        New_Pos := []
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] := Math.Log10(NDArray[i*])
        
        Return NDArray
    }
    
    Static Max(NDArray)
    {
        New_Pos := []
        Max_Num := "None"
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
        {
            if Max_Num !== "None"
                Max_Num := (NDArray[i*] > Max_Num) ? NDArray[i*] : Max_Num
            
            else
                Max_Num := NDArray[i*]
        }
        
        Return Max_Num
    }

    Static Mean(NDArray, Axis := "axis=-1")
    {
        if InStr(Axis, "=")
            Axis := Trim(StrSplit(Axis, "=")[2])
        
        if Axis == -1
            Axis := NDArray.ndim - 1
        
        if NDArray.ndim == 1
        {
            sum := 0
            
            For i in NDArray.array
                sum += i
            
            Return sum / NDArray.array.Length
        }
        
        else
        {
            Lst_Res := List()
            Lst_Pos := List()
            
            Loop NDArray.ndim
            {
                if Axis == A_Index - 1
                    Lst_Pos.Append([":"])
                
                else
                    Lst_Pos.Append(Range(NDArray.Shape[A_Index - 1]))
            }
            
            Lst_Pos := Dynloop_Loop(Lst_Pos)
            
            For i in Lst_Pos
                Lst_Res.Append(Numahk.Mean(Numahk.array(NDArray[i*])))
            
            Lst_Res := Numahk.array(Lst_Res)
            NDArray.shape.RemoveAt(Axis + 1)
            Lst_Res.reshape(NDArray.shape*)
            
            Return Lst_Res
        }
    }
    
    Static Min(NDArray)
    {
        New_Pos := []
        Min_Num := "None"
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
        {
            if Min_Num !== "None"
                Min_Num := (NDArray[i*] < Min_Num) ? NDArray[i*] : Min_Num
            
            else
                Min_Num := NDArray[i*]
        }
        
        Return Min_Num
    }
    
    Static Mul(NDArray, Number := 1)
    {
        New_Pos := []
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] *= Number
        
        Return NDArray
    }
    
    Static Multiple(NDArray*)
    {
        New_Pos := []
        
        For i in NDArray[1].shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
        {
            Loop NDArray.Length - 1
                NDArray[1][i*] *= NDArray[A_Index + 1][i*]
        }
        
        Return NDArray[1]
    }
    
    Static Not_Equal(NDArray1, NDArray2)
    {
        New_Pos := []
        NDArray := Numahk.Zeros(NDArray1.Shape)
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] := (NDArray1[i*] !== NDArray2[i*])
        
        Return NDArray
    }
    
    Static Numbers(Shape, Number := 1)
    {
        Res_Lst := List()
        Res_Lst.Append(Number)
        
        Loop Shape.Length
        {
            Res_Lst.multiple(Shape[-A_Index])
            
            if A_Index !== Shape.Length
            {
                temp := List()
                temp.Append(Res_Lst)
                Res_Lst := temp
            }
        }
        
        Res_Lst := Numahk.array(Res_Lst)
        
        Return Res_Lst
    }
    
    Static Offset(NDArray, Axis := "axis=-1")
    {
        if InStr(Axis, "=")
            Axis := Trim(StrSplit(Axis, "=")[2])
        
        if Axis == -1
            Axis := NDArray.ndim - 1
        
        if NDArray.ndim == 1
        {
            sum := 0
            
            For i in NDArray.array
                sum += i
            
            avg := sum / NDArray.array.Length
            sum := 0
            
            For i in NDArray.array
                sum += (i - avg) ** 2
            
            Return sum
        }
        
        else
        {
            Lst_Res := List()
            Lst_Pos := List()
            
            Loop NDArray.ndim
            {
                if Axis == A_Index - 1
                    Lst_Pos.Append([":"])
                
                else
                    Lst_Pos.Append(Range(NDArray.Shape[A_Index - 1]))
            }
            
            Lst_Pos := Dynloop_Loop(Lst_Pos)
            
            For i in Lst_Pos
                Lst_Res.Append(Numahk.Offset(Numahk.array(NDArray[i*])))
            
            Lst_Res := Numahk.array(Lst_Res)
            NDArray.shape.RemoveAt(Axis + 1)
            Lst_Res.reshape(NDArray.shape*)
            
            Return Lst_Res
        }
    }
    
    Static Ones(Shape)
    {
        Res_Lst := List()
        Res_Lst.Append(1)
        
        Loop Shape.Length
        {
            Res_Lst.multiple(Shape[-A_Index])
            
            if A_Index !== Shape.Length
            {
                temp := List()
                temp.Append(Res_Lst)
                Res_Lst := temp
            }
        }
        
        Res_Lst := Numahk.array(Res_Lst)
        
        Return Res_Lst
    }
    
    Static Plus(NDArray*)
    {
        New_Pos := []
        
        For i in NDArray[1].shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
        {
            Loop NDArray.Length - 1
                NDArray[1][i*] += NDArray[A_Index + 1][i*]
        }
        
        Return NDArray[1]
    }
    
    Static Pow(NDArray, Number*)
    {
        New_Pos := []
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] := Math.Pow(NDArray[i*], Number*)
        
        Return NDArray
    }
    
    Static R_(NDArray*)
    {
        Lst_Res := List()
        
        For i in NDArray
        {
            if Type(i) == "String"
                NDArray[A_Index] := List(StrSplit(i, "")*)
            
            else if ListIn(["Integer", "Float"], Type(i)) !== "Not Found"
                NDArray[A_Index] := List(i)
            
            else if Type(i) == "Numahk.NDArray"
                NDArray[A_Index] := Numahk.tolist(i)
        }
        
        Loop NDArray.Length
            Lst_Res.Extend(NDArray[A_Index])
        
        Return Lst_Res
    }
    
    Static Reshape(Lst, Shape)
    {
        Mul := 1
        Shape := List(Shape*)
        Lst_Temp := List()
        Lst_Temp2 := List()
        
        Summary := ToString(Lst)
        Summary := StrReplace(Summary, '"')
        Summary := StrReplace(Summary, "[")
        Summary := StrReplace(Summary, "]")
        Lst_Summary := StrSplit(Summary, ",")
        
        Loop Shape.Length
            Mul *= Shape[A_Index - 1]
        
        Loop Shape.Length
        {
            Last := Shape.Pop()
            Mul //= Last
            
            Loop Mul
            {
                Loop Last
                    Lst_Temp2.Append(Lst_Summary.RemoveAt(1))
                
                Lst_Temp.Append(Lst_Temp2)
                Lst_Temp2 := List()
            }
            
            Lst_Summary := Lst_Temp.Clone()
            Lst_Temp := List()
        }
        
        Return Lst_Summary[0]
    }
    
    Static Size(NDArray, Number := -1)
    {
        if Number < 0
            Return NDArray.size
        
        else
            Return NDArray.shape[Number]
    }
    
    Static Sort(NDArray)
    {
        Lst_NDArray := NDArray.Ravel()
        
        For i in XRange(Lst_NDArray.array.Length)
        {
            For j in XRange(i + 1, Lst_NDArray.array.Length)
            {
                if Lst_NDArray[i] > Lst_NDArray[j]
                {
                    Temp := Lst_NDArray[i]
                    Lst_NDArray[i] := Lst_NDArray[j]
                    Lst_NDArray[j] := Temp
                }
            }
        }
        
        Return Lst_NDArray
    }
    
    Static Std(NDArray, Axis := "axis=-1")
    {
        if InStr(Axis, "=")
            Axis := Trim(StrSplit(Axis, "=")[2])
        
        if Axis == -1
            Axis := NDArray.ndim - 1
        
        if NDArray.ndim == 1
        {
            sum := 0
            
            For i in NDArray.array
                sum += i
            
            avg := sum / NDArray.array.Length
            sum := 0
            
            For i in NDArray.array
                sum += (i - avg) ** 2
            
            Return Math.Sqrt(sum / NDArray.array.Length)
        }
        
        else
        {
            Lst_Res := List()
            Lst_Pos := List()
            
            Loop NDArray.ndim
            {
                if Axis == A_Index - 1
                    Lst_Pos.Append([":"])
                
                else
                    Lst_Pos.Append(Range(NDArray.Shape[A_Index - 1]))
            }
            
            Lst_Pos := Dynloop_Loop(Lst_Pos)
            
            For i in Lst_Pos
                Lst_Res.Append(Numahk.Std(Numahk.array(NDArray[i*])))
            
            Lst_Res := Numahk.array(Lst_Res)
            NDArray.shape.RemoveAt(Axis + 1)
            Lst_Res.reshape(NDArray.shape*)
            
            Return Lst_Res
        }
    }
    
    Static Sqrt(NDArray)
    {
        New_Pos := []
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] := Math.Sqrt(NDArray[i*])
        
        Return NDArray
    }
    
    Static Sub(NDArray, Number := 0)
    {
        New_Pos := []
        
        For i in NDArray.shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
            NDArray[i*] -= Number
        
        Return NDArray
    }
    
    Static Subtract(NDArray*)
    {
        New_Pos := []
        
        For i in NDArray[1].shape
            New_Pos.Push(Range(0, i))
        
        New_Pos := Dynloop_Loop(New_Pos)
        
        For i in New_Pos
        {
            Loop NDArray.Length - 1
                NDArray[1][i*] -= NDArray[A_Index + 1][i*]
        }
        
        Return NDArray[1]
    }
    
    Static Sum(NDArray, Axis := "axis=-1")
    {
        if InStr(Axis, "=")
            Axis := Trim(StrSplit(Axis, "=")[2])
        
        Return NDArray.Sum(Axis)
    }
    
    Static ToList(NDArray)
    {
        Temp := List()
        
        For i in NDArray.shape
            Temp.Append(Range(i))
        
        Lst_Temp := Dynloop_Loop(Temp)
        Temp := List()
        
        For i in Lst_Temp
            Temp.Append(NDArray[i*])
        
        Return Numahk.Reshape(Temp, NDArray.shape)
    }
    
    Static ToNDArray(Lst)
    {
        Res_Lst := Numahk.NDArray()
        Res_Lst.shape := List()
        Res_Lst.size := 1
        Lst_Type := ["Array", "List", "ComObjArray"]
        
        if ListIn(Lst_Type, Type(Lst)) !== "Not Found"
        {
            For i in Lst
            {
                Res_i := Numahk.ToNDArray(i)
                Res_Lst.array.Append(Res_i)
                
                if Type(Res_i) !== "Numahk.NDArray"
                    Res_Lst.ndim := 1
                
                else
                    Res_Lst.ndim := (Res_Lst.ndim < 1 + Res_i.ndim) ? (1 + Res_i.ndim) : Res_Lst.ndim
            }
        }
        
        else
            Return Lst
        
        temp := Res_Lst.Clone()
            
        Loop Res_Lst.ndim
        {
            Res_Lst.shape.Append(temp.array.Length)
            Res_Lst.size *= temp.array.Length
            
            if A_Index !== Res_Lst.ndim
                temp := temp.array[0]
        }
        
        Return Res_Lst
    }
    
    Static Transpose(NDArray)
    {
        New_Shape := NDArray.shape.Clone()
        New_Shape.Push(New_Shape.RemoveAt(1))
        
        New_NDArray := Numahk.Zeros(New_Shape)
        
        Pos_Old := List()
        Pos_New := List()
        
        Loop NDArray.Shape.Length
            Pos_Old.Append(Range(0, NDArray.Shape[-A_Index]))
        
        Pos_Old.reverse()
        Pos_Old := Dynloop_Loop(Pos_Old)
        
        For i in Pos_Old
        {
            k := i.Clone()
            Temp := k.RemoveAt(1)
            k.Push(Temp)
            Pos_New.Append(k)
        }
        
        Loop Pos_Old.Length
            New_NDArray[Pos_New[A_Index - 1]*] := NDArray[Pos_Old[A_Index - 1]*]
        
        Return New_NDArray
    }
    
    Static Unique(NDArray)
    {
        Lst_Res := List()
        
        For i in NDArray.array
        {
            if ListIn(Lst_Res, i) == "Not Found"
                Lst_Res.Append(i)
        }
        
        Return Numahk.array(Lst_Res)
    }
    
    Static Var(NDArray, Axis := "axis=-1")
    {
        if InStr(Axis, "=")
            Axis := Trim(StrSplit(Axis, "=")[2])
        
        if Axis == -1
            Axis := NDArray.ndim - 1
        
        if NDArray.ndim == 1
        {
            sum := 0
            
            For i in NDArray.array
                sum += i
            
            avg := sum / NDArray.array.Length
            sum := 0
            
            For i in NDArray.array
                sum += (i - avg) ** 2
            
            Return sum / NDArray.array.Length
        }
        
        else
        {
            Lst_Res := List()
            Lst_Pos := List()
            
            Loop NDArray.ndim
            {
                if Axis == A_Index - 1
                    Lst_Pos.Append([":"])
                
                else
                    Lst_Pos.Append(Range(NDArray.Shape[A_Index - 1]))
            }
            
            Lst_Pos := Dynloop_Loop(Lst_Pos)
            
            For i in Lst_Pos
                Lst_Res.Append(Numahk.Var(Numahk.array(NDArray[i*])))
            
            Lst_Res := Numahk.array(Lst_Res)
            NDArray.shape.RemoveAt(Axis + 1)
            Lst_Res.reshape(NDArray.shape*)
            
            Return Lst_Res
        }
    }
    
    Static VStack(NDArray*)
    {
        if NDArray.Length == 1
            NDArray := NDArray[1]
        
        Lst_NDArray := List()
        
        For i in NDArray
        {
            if Type(i) == "String"
                i := List(StrSplit(i, "")*)
            
            else if Type(i) == "Numahk.NDArray"
                i := i.array
            
            Lst_NDArray.Extend(i)
        }
        
        Return Numahk.array(Lst_NDArray)
    }
    
    Static Zeros(Shape)
    {
        if ListIn(["Integer", "String"], Type(Shape)) !== "Not Found"
            Shape := [Shape]
        
        Res_Lst := List()
        Res_Lst.Append(0)
        
        Loop Shape.Length
        {
            Res_Lst.multiple(Shape[-A_Index])
            
            if A_Index !== Shape.Length
            {
                temp := List()
                temp.Append(Res_Lst)
                Res_Lst := temp
            }
        }
        
        Res_Lst := Numahk.array(Res_Lst)
        
        Return Res_Lst
    }
    
    Static Zeros_Like(NDArray)
    {
        Shape := NDArray.shape
        Res_Lst := List()
        Res_Lst.Append(0)
        
        Loop Shape.Length
        {
            Res_Lst.multiple(Shape[-A_Index])
            
            if A_Index !== Shape.Length
            {
                temp := List()
                temp.Append(Res_Lst)
                Res_Lst := temp
            }
        }
        
        Res_Lst := Numahk.array(Res_Lst)
        
        Return Res_Lst
    }
    
    Class Linalg
    {
        Static Inv(NDArray)
        {
            n := NDArray.Shape[0]
            index := 0
            NDArrayTemp := NDArray.Copy()
            Zeros := Numahk.Zeros(NDArray.Shape)
            
            For i in Zeros
            {
                i[index] := 1
                index++
            }
            
            For k in range(0, n - 1)  
            {  
                For i in range(k + 1, n)  
                {
                    m := NDArrayTemp[i, k] / NDArrayTemp[k, k]
                    
                    For j in range(0, n)
                    {  
                        NDArrayTemp[i, j] := NDArrayTemp[i, j] - m * NDArrayTemp[k, j]
                        Zeros[i, j] := Zeros[i, j] - m * Zeros[k, j]
                    }
                }
            }
            
            For k in range(0, n - 1)  
            {
                k := n - 1 - k
                
                For i in range(0, k)  
                {
                    i := k - 1 - i
                    m := NDArrayTemp[i, k] / NDArrayTemp[k, k]
                    
                    For j in range(0, n)
                    {  
                        NDArrayTemp[i, j] := NDArrayTemp[i, j] - m * NDArrayTemp[k, j]
                        Zeros[i, j] := Zeros[i, j] - m * Zeros[k, j]
                    }
                }
            }
            
            For i in range(0, n)
            {
                For j in range(0, n)
                    Zeros[i, j] := Zeros[i, j] / NDArrayTemp[i, i]
            }
            
            Return Zeros
        }
        
        Static Norm(NDArray, Param*)
        {
            Temp :=
            {
                Ord : 2,
                Axis : -1,
                Keepdims : False
            }
            
            For i in Param
            {
                if InStr(i, "=")
                {
                    if InStr(StrTitle(i), "Ord")
                        Temp.Ord := Trim(StrSplit(i, "=")[2])
                    
                    if InStr(StrTitle(i), "Axis")
                        Temp.Axis := Trim(StrSplit(i, "=")[2])
                    
                    if InStr(StrTitle(i), "Keepdims")
                    {
                        Temp.Keepdims := Trim(StrSplit(i, "=")[2])
                        Temp.Keepdims := (i == "True") ? True : False
                    }
                }
            }
            
            if Temp.Axis == -1
                Temp.Axis := NDArray.ndim - 1
            
            if NDArray.ndim == 1
                Return Numahk.Linalg.OrdCalc(NDArray.array, Temp.Ord)
            
            else
            {
                Lst_Res := List()
                Lst_Pos := List()
                
                Loop NDArray.ndim
                {
                    if Temp.Axis == A_Index - 1
                        Lst_Pos.Append([":"])
                    
                    else
                        Lst_Pos.Append(Range(NDArray.Shape[A_Index - 1]))
                }
                
                Lst_Pos := Dynloop_Loop(Lst_Pos)
                
                For i in Lst_Pos
                    Lst_Res.Append(Numahk.Linalg.OrdCalc(Numahk.array(NDArray[i*]).array, Temp.Ord))
                
                Lst_Res := Numahk.array(Lst_Res)
                NDArray.shape.RemoveAt(Temp.Axis + 1)
                Lst_Res.reshape(NDArray.shape*)
                
                Return Numahk.ToList(Lst_Res)
            }
        }
        
        Static OrdCalc(Lst, Type := 2)
        {
            Res := 0
            
            if Type == 1
            {
                For i in Lst
                    Res += Math.Abs(i)
            }
            
            else if Type == 2
            {
                For i in Lst
                    Res += Math.Pow(i, 2)
                
                Res := Math.Sqrt(Res)
            }
            
            else if Type == "np.inf"
            {
                max_num := Lst[-Lst.Length]
                
                For i in Lst
                {
                    if i > max_num
                        max_num := i
                }
                
                Res := max_num
            }
            
            Return Res
        }
        
        Static Slogdet(NDArray)
        {
            n := NDArray.Shape[0]
            index := 0
            NDArrayTemp := NDArray.Copy()
            
            For k in range(0, n - 1)  
            {  
                For i in range(k + 1, n)  
                {
                    m := NDArrayTemp[i, k] / NDArrayTemp[k, k]
                    
                    For j in range(0, n)
                        NDArrayTemp[i, j] := NDArrayTemp[i, j] - m * NDArrayTemp[k, j]
                }
            }
            
            Res := 1
            
            For i in range(0, n)
                Res *= NDArrayTemp[i, i]
            
            Sign := (Res < 0) ? -1 : 1
            Res := Res / Sign
            
            Return List(Sign, Math.Log(Res))
        }
        
        Static Solve(NDArray1, NDArray2)
        {
            Return Numahk.Dot(Numahk.Linalg.Inv(NDArray1), NDarray2)
        }
    }
    
    Class NDArray Extends List
    {
        __New(Lst*)
        {
            For i in Lst
                Lst := i
            
            this.ndim := 1
            this.array := List()
            this.shape := List()
            this.size := 1
            
            For i in Lst
            {
                Res_i := Numahk.ToNDArray(i)
                this.array.Append(Res_i)
                
                if Type(Res_i) == "Numahk.NDArray"
                    this.ndim := (this.ndim < 1 + Res_i.ndim) ? (1 + Res_i.ndim) : this.ndim
            }
            
            temp := this.Clone()
            
            Loop this.ndim
            {
                this.shape.Append(temp.array.Length)
                this.size *= temp.array.Length
                
                if A_Index !== this.ndim
                    temp := temp.array[0]
            }
        }
        
        __Enum(Number)
        {
            Index := this.array.Length
            
            Return Fn
            
            Fn(&idx := 0, &value := 0)
            {
                if IsSet(value)
                {
                    Try
                    {
                        idx := this.array[this.array.Length - Index]
                        Return Index-- >= 0
                    }
                    
                    Catch
                        Return 0
                }
                
                else
                {
                    Try
                    {
                        idx := this.array.Length - Index
                        value := this.array[this.array.Length - Index]
                        Return Index-- >= 0
                    }
                    
                    Catch
                        Return 0
                }
            }
        }
        
        __Item[Param*]
        {
            Get => (this.GetElement(Param).array.Length > 1) ? this.GetElement(Param).array : this.GetElement(Param).array[0]
            Set => this.SetElement(Param, Value)
        }
        
        Add(Number := 0)
        {
            New_Pos := []
            
            For i in this.shape
                New_Pos.Push(Range(0, i))
            
            New_Pos := Dynloop_Loop(New_Pos)
            
            For i in New_Pos
                this[i*] += Number
        }
        
        Copy()
        {
            New_NDArray := this.ravel()
            New_NDArray.reshape(this.shape*)
            
            Return New_NDArray
        }
        
        Div(Number := 1)
        {
            New_Pos := []
            
            For i in this.shape
                New_Pos.Push(Range(0, i))
            
            New_Pos := Dynloop_Loop(New_Pos)
            
            For i in New_Pos
                this[i*] /= Number
        }
        
        GetElement(Param)
        {
            TempArray := this.Clone()
            Lst_Range := List()
            Get_Element := List()
            
            For i in Param
            {
                Lst_i := StrSplit(i, ":")
                
                if Lst_i.Length < 2
                {
                    Temp := List()
                    Temp.Append(Integer(Lst_i[1]))
                    Lst_Range.Append(Temp)
                }
                
                else if Lst_i.Length == 2
                {
                    Lst_i[1] := (Lst_i[1] == "") ? 0 : Lst_i[1]
                    Lst_i[2] := (Lst_i[2] == "") ? this.shape[A_Index - 1] : Lst_i[2]
                    Lst_Range.Append(Range(Integer(Lst_i[1]), Integer(Lst_i[2])))
                }
                
                else
                {
                    Lst_i[1] := (Lst_i[1] == "") ? 0 : Lst_i[1]
                    Lst_i[2] := (Lst_i[2] == "") ? this.shape[A_Index - 1] : Lst_i[2]
                    Lst_Range.Append(Range(Integer(Lst_i[1]), Integer(Lst_i[2]), Integer(Lst_i[3])))
                }
            }
            
            Temp := Dynloop_Loop(Lst_Range)
            
            Loop Temp.Length
            {
                index := A_Index - 1
                Lst_Temp := TempArray.Clone()
                
                Loop Lst_Range.Length
                    Lst_Temp := Lst_Temp.array[Temp[index][A_Index - 1]]
                
                Get_Element.Append(Lst_Temp)
            }
            
            Return Numahk.ToNDArray(Get_Element)
        }
        
        Mean(Axis := "axis=-1")
        {
            if InStr(Axis, "=")
                Axis := Trim(StrSplit(Axis, "=")[2])
            
            if Axis == -1
                Axis := this.ndim - 1
            
            Return Numahk.Mean(this, Axis)
        }
    
        Mul(Number := 1)
        {
            New_Pos := []
            
            For i in this.shape
                New_Pos.Push(Range(0, i))
            
            New_Pos := Dynloop_Loop(New_Pos)
            
            For i in New_Pos
                this[i*] *= Number
        }
        
        Ravel()
        {
            New_NDArray := []
            
            Summary := ToString(this)
            Summary := StrReplace(Summary, '"')
            Summary := StrReplace(Summary, "[")
            Summary := StrReplace(Summary, "]")
            Lst_Summary := StrSplit(Summary, ",")
            
            Loop Lst_Summary.Length
                New_NDArray.Push(Lst_Summary[A_Index])
            
            Return Numahk.array(New_NDArray)
        }
        
        Reshape(Shape*)
        {
            if ListIn(["Integer", "Float", "String"], Type(Shape[1])) == "Not Found"
                Shape := Shape[1]
            
            Shape := List(Shape*)
            Mul := 1
            index := -1
            
            For i in Shape
            {
                if i == -1
                    index := A_Index - 1
                
                else
                    Mul *= Shape[A_Index - 1]
            }
            
            if index !== -1
                Shape[index] := this.size // Mul
            
            Mul := 1
            
            Loop Shape.Length
                Mul *= Shape[A_Index - 1]
            
            if Mul == this.size
            {
                Num := ToString(this)
                Num := StrReplace(Num, '"')
                Num := StrReplace(Num, "[")
                Num := StrReplace(Num, "]")
                Lst_Num := StrSplit(Num, ",")
                Lst_Temp := []
                Lst_Temp2 := []
                
                Loop Shape.Length
                {
                    Last := Shape.Pop()
                    Mul //= Last
                    
                    Loop Mul
                    {
                        Loop Last
                            Lst_Temp2.Push(Lst_Num.RemoveAt(1))
                        
                        Lst_Temp.Push(Lst_Temp2)
                        Lst_Temp2 := []
                    }
                    
                    Lst_Num := Lst_Temp.Clone()
                    Lst_Temp := []
                }
                
                ReshapeArray := Numahk.array(Lst_Num*)
                
                this.ndim := ReshapeArray.ndim
                this.array := ReshapeArray.array
                this.shape := ReshapeArray.shape
                this.size := ReshapeArray.size
            }
            
            Return this
        }
        
        SetElement(Param, Value)
        {
            TempArray := this.Clone()
            Lst_Range := List()
            Get_Element := List()
            
            For i in Param
            {
                Lst_i := StrSplit(i, ":")
                
                if Lst_i.Length < 2
                {
                    Temp := List()
                    Temp.Append(Integer(Lst_i[1]))
                    Lst_Range.Append(Temp)
                }
                
                else if Lst_i.Length == 2
                {
                    Lst_i[1] := (Lst_i[1] == "") ? 0 : Lst_i[1]
                    Lst_i[2] := (Lst_i[2] == "") ? this.shape[A_Index - 1] : Lst_i[2]
                    Lst_Range.Append(Range(Integer(Lst_i[1]), Integer(Lst_i[2])))
                }
                
                else
                {
                    Lst_i[1] := (Lst_i[1] == "") ? 0 : Lst_i[1]
                    Lst_i[2] := (Lst_i[2] == "") ? this.shape[A_Index - 1] : Lst_i[2]
                    Lst_Range.Append(Range(Integer(Lst_i[1]), Integer(Lst_i[2]), Integer(Lst_i[3])))
                }
            }
            
            Temp := Dynloop_Loop(Lst_Range)
            
            For i in Temp
                this.SetSingleElement(i, Value)
        }
        
        SetSingleElement(Param, Value)
        {
            Temp := this.array
            
            Loop Param.Length - 1
            {
                Temp2 := Temp[Integer(Param[A_Index - 1])].array
                Temp := Temp2
            }
            
            if ListIn(["Integer", "String", "Float", "Numahk.NDArray"], Type(Value)) == "Not Found"
                Temp[Integer(Param[Param.Length - 1])] := Numahk.array([Value]*)
            
            else
                Temp[Integer(Param[Param.Length - 1])] := Value
        }
    
        Sqrt()
        {
            New_Pos := []
            
            For i in this.shape
                New_Pos.Push(Range(0, i))
            
            New_Pos := Dynloop_Loop(New_Pos)
            
            For i in New_Pos
                this[i*] := Math.Sqrt(this[i*])
        }
        
        Sub(Number := 0)
        {
            New_Pos := []
            
            For i in this.shape
                New_Pos.Push(Range(0, i))
            
            New_Pos := Dynloop_Loop(New_Pos)
            
            For i in New_Pos
                this[i*] -= Number
        }
        
        Sum(Axis := "axis=-1")
        {
            if InStr(Axis, "=")
                Axis := Trim(StrSplit(Axis, "=")[2])
            New_NDArray := []
            
            if Axis == -1
            {
                Summary := ToString(this)
                Summary := StrReplace(Summary, '"')
                Summary := StrReplace(Summary, "[")
                Summary := StrReplace(Summary, "]")
                Lst_Summary := StrSplit(Summary, ",")
                Summary := 0
                
                Loop Lst_Summary.Length
                    Summary += Lst_Summary[A_Index]
                
                Return Summary
            }
            
            else if Axis == 0
            {
                Loop this.array.Length
                    New_NDArray.Push(this.array[A_Index - 1])
                
                if Type(New_NDArray[1]) == "Numahk.NDArray"
                    Return Numahk.Plus(New_NDArray*)
                
                else
                {
                    Summary := 0
                    
                    Loop New_NDArray.Length
                        Summary += New_NDArray[A_Index]
                    
                    Return Summary
                }
            }
            
            else
            {
                Loop this.array.Length
                    New_NDArray.Push(this.array[A_Index - 1].Sum(Axis - 1))
                
                Return Numahk.array(New_NDArray)
            }
        }
        
        Transpose()
        {
            New_NDArray := Numahk.Transpose(this)
            
            this.ndim := New_NDArray.ndim
            this.array := New_NDArray.array
            this.shape := New_NDArray.shape
            this.size := New_NDArray.size
            
            Return this
        }
    }
    
    Class Random
    {
        Static Rand(Shape*)
        {
            New_NDArray := []
            
            if Shape.Length == 1
            {
                Loop Shape[-1]
                    New_NDArray.Push(Random.Random())
                
                Return Numahk.ToList(Numahk.array(New_NDArray))
            }
            
            else
            {
                Temp := Shape.Clone()
                Loop_Times := Temp.RemoveAt(1)
                Shape := Temp.Clone()

                Loop Loop_Times
                    New_NDArray.Push(Numahk.Random.Rand(Shape*))
                
                Return Numahk.ToList(Numahk.array(New_NDArray))
            }
        }
        
        Static Randf(Start, Stop, Shape)
        {
            New_NDArray := []
            
            if Shape.Length == 1
            {
                Loop Shape[-1]
                    New_NDArray.Push(Random.Random(Start, Float(Stop)))
                
                Return Numahk.ToList(Numahk.array(New_NDArray))
            }
            
            else
            {
                Temp := Shape.Clone()
                Loop_Times := Temp.RemoveAt(1)
                Shape := Temp.Clone()
                
                Loop Loop_Times
                    New_NDArray.Push(Numahk.Random.Randf(Start, Stop, Shape))
                
                Return Numahk.ToList(Numahk.array(New_NDArray))
            }
        }
        
        Static Randi(Start, Stop, Shape)
        {
            New_NDArray := []
            
            if Shape.Length == 1
            {
                Loop Shape[-1]
                    New_NDArray.Push(Integer(Random.Random(Start, Stop - 1)))
                
                Return Numahk.ToList(Numahk.array(New_NDArray))
            }
            
            else
            {
                Temp := Shape.Clone()
                Loop_Times := Temp.RemoveAt(1)
                Shape := Temp.Clone()
                
                Loop Loop_Times
                    New_NDArray.Push(Numahk.Random.Randi(Start, Stop ,Shape))
                
                Return Numahk.ToList(Numahk.array(New_NDArray))
            }
        }
        
        Static Randint(Stop, Start := 0, Size := "size=1", Swap := -1)
        {
            if Swap == -1 && Start
            {
                Temp := Stop
                Stop := Start
                Start := Temp
            }
            
            New_Shape := []
            
            if InStr(Size, "=")
                Size := Trim(StrSplit(Size, "=")[2])
            
            Lst_Size := StrSplit(Size, ",")
            
            Loop Lst_Size.Length
            {
                Lst_Size[A_Index] := StrReplace(Lst_Size[A_Index], "(")
                Lst_Size[A_Index] := StrReplace(Lst_Size[A_Index], ")")
                Lst_Size[A_Index] := StrReplace(Lst_Size[A_Index], "[")
                Lst_Size[A_Index] := StrReplace(Lst_Size[A_Index], "]")
                New_Shape.Push(Lst_Size[A_Index])
            }
            
            Return Numahk.Random.Randi(Start, Stop, New_Shape)
        }
        
        Static Randn(Shape*)
        {
            New_NDArray := []
            
            if Shape.Length == 1
            {
                New_NDArray.Push(Random.Randn(Shape[-1]))
                
                Return Numahk.ToList(Numahk.array(New_NDArray*))
            }
            
            else
            {
                Temp := Shape.Clone()
                Loop_Times := Temp.RemoveAt(1)
                Shape := Temp.Clone()
                
                Loop Loop_Times
                    New_NDArray.Push(Numahk.Random.Randn(Shape*))
                
                Return Numahk.ToList(Numahk.array(New_NDArray))
            }
        }
        
        Static Random(Shape*)
        {
            New_NDArray := []
            
            if ListIn(["Integer", "Float", "String"], Type(Shape[1])) == "Not Found"
                Shape := Shape[1]
            
            if Shape.Length == 1
            {
                Loop Shape[-1]
                    New_NDArray.Push(Random.Random())
                
                Return Numahk.ToList(Numahk.array(New_NDArray))
            }
            
            else
            {
                Temp := Shape.Clone()
                Loop_Times := Temp.RemoveAt(1)
                Shape := Temp.Clone()
                
                Loop Loop_Times
                    New_NDArray.Push(Numahk.Random.Random(Shape*))
                
                Return Numahk.ToList(Numahk.array(New_NDArray))
            }
        }
    }
}

Class Dict Extends Map
{
    __Item[Key]
    {
        Get => Super[Key]
        Set => Super[Key] := Value
    }
    
    Clear()
    {
        this.Clear()
    }
    
    Copy()
    {
        Return this.Clone()
    }
    
    Get(Key, Default := "None")
    {
        if this.Has(Key)
            Return this[Key]
        
        Return Default
    }
    
    HasKey(Key)
    {
        Return this.Has(Key)
    }
    
    Items()
    {
        Lst_Dict := List()
        
        For i, Value in Dict
            Lst_Dict.Append(List(i, Value))
        
        Return Lst_Dict
    }
    
    Keys()
    {
        Lst_Dict := List()
        
        For i, Value in this
            Lst_Dict.Append(i)
        
        Return Lst_Dict
    }
    
    Pop(Key, Default := "None")
    {
        Try
            Return this.Delete(Key)
        
        Catch
            Return Default
    }
    
    PopItem()
    {
        Last_Key := ""
        
        For i, Value in this
            Last_Key := i
        
        Lst_Last_Key := List()
        Lst_Last_Key.Append(List(Last_Key, this.Delete(Last_Key)))
        
        Return Lst_Last_Key
    }
    
    SetDefault(Key, Default := 0)
    {
        if this.Has(Key)
            Return this[Key]
        
        else
        {
            this[Key] := Default
            
            Return Default
        }
    }
    
    Str()
    {
        Return ToString(this)
    }
    
    Subtract(New_Dict)
    {
        Sub_Dict := Dict()
        
        For i, Value in this
        {
            if !New_Dict.Has(i)
                Sub_Dict[i] := Value
        }
        
        Return Sub_Dict
    }
    
    Update(New_Dict)
    {
        For i, Value in New_Dict
            this[i] := Value
    }
    
    Values()
    {
        Lst_Dict := List()
        
        For i, Value in this
            Lst_Dict.Append(Value)
        
        Return Lst_Dict
    }
}

Class List Extends Array
{
    NextIdx := 0
    
    __Enum(Number)
    {
        Index := this.Length
        
        Return Fn
        
        Fn(&idx := 0, &value := 0)
        {
            if IsSet(value)
            {
                Try
                {
                    idx := this[this.Length - Index]
                    Return Index-- >= 0
                }
                
                Catch
                    Return 0
            }
            
            else
            {
                Try
                {
                    idx := this.Length - Index
                    value := this[this.Length - Index]
                    Return Index-- >= 0
                }
                
                Catch
                    Return 0
            }
        }
    }
    
    __Item[Index]
    {
        Get => this.GetMethod(Index)
        Set => this.SetMethod(Index, Value)
    }
    
    Append(Object*)
    {
        Loop Object.Length
            this.Push(Object[A_Index])
    }
    
    Count(Object)
    {
        Return_Count := 0
        
        For i in this
        {
            if !ListCmp(i, Object)
                Return_Count++
        }
        
        Return Return_Count
    }
    
    Extend(Extend_Lst*)
    {
        Loop Extend_Lst.Length
        {
            if Type(Extend_Lst[A_Index]) !== "Array" && Type(Extend_Lst[A_Index]) !== "List"
                this.Push(Extend_Lst[A_Index])
            
            else
            {
                For i in Extend_Lst[A_Index]
                    this.Push(i)
            }
        }
    }
    
    GetMethod(Index)
    {
        Try
            Index := Integer(Index)
        
        if Type(Index) == "Integer"
            Return Super[this.Init(Index)]
        
        else if InStr(Index, ":")
        {
            Lst_Res := List()
            Lst_Index := StrSplit(Index, ":")
            
            if !Trim(Lst_Index[1])
                Lst_Index[1] := 0
            
            if !Trim(Lst_Index[2])
                Lst_Index[2] := this.Length
            
            For i in XRange(Trim(Lst_Index[1]), Trim(Lst_Index[2]))
                Lst_Res.Append(Super[this.Init(i)])
            
            Return Lst_Res
        }
    }
    
    Index(Object)
    {
        Flag := 0
        Index := 0
        
        For i in this
        {
            if !ListCmp(i, Object)
            {
                Flag := 1
                Break
            }
            
            Index++
        }
        
        if !Flag
            Index := -1
        
        Return Index
    }
    
    Init(Index)
    {
        if Index >= 0
            Index += 1
        
        Return Index
    }
    
    Insert(Index, Object*)
    {
        this.InsertAt(this.Init(Index), Object*)
    }
    
    List(Lst*)
    {
        Return this.Plus(Lst*)
    }
    
    ListMap(Map)
    {
        Lst_Map := List()
    
        if Type(Map) !== "Map" && Type(Map) !== "Dict"
            Return "Illegal Input"
            
        else
        {
            For i, Value in Map
                Lst_Map.Append([i, Value])
            
            Return Lst_Map
        }
    }
    
    Max()
    {
        Return Max(this*)
    }
    
    Min()
    {
        Return Min(this*)
    }
    
    Multiple(Number)
    {
        Lst := this.Clone()
        
        Loop Number - 1
        {
            For i in Lst
            {
                Try
                {
                    this.Append(i.Clone())
                    Continue
                }
                
                Catch
                    Error := 1
                
                this.Append(i)
            }
        }
    }
    
    Next()
    {
        if this.NextIdx <= 0
            this.NextIdx := this.Length
        
        Res := this[this.Length - this.NextIdx]
        this.NextIdx--
        
        Return Res
    }

    Plus(Lst*)
    {
        Loop Lst.Length
        {
            if Type(Lst[A_Index]) !== "Array" && Type(Lst[A_Index]) !== "List"
                this.Append(Lst[A_Index])
            
            else
            {
                For i in Lst[A_Index]
                    this.Append(i)
            }
        }
    }
    
    Pop(Index := -1)
    {
        if Index == -1 || Index >= this.Length
            Return this.RemoveAt(-1)
        
        else
            Return this.RemoveAt(this.Init(Index))
    }
    
    Remove(Object*)
    {
        Loop Object.Length
        {
            Index := this.Index(Object[A_Index])
            
            if Index != -1
                this.Pop(Index)
        }
    }
    
    Reverse()
    {
        Loop this.Length // 2
            Swap(A_Index - 1, this.Length - A_Index, this)
    }
    
    SetMethod(Index, Value)
    {
        Try
            Index := Integer(Index)
        
        if Type(Index) == "Integer"
            Super[this.Init(Index)] := Value
        
        else if InStr(Index, ":")
        {
            Lst_Index := StrSplit(Index, ":")
            
            if !Trim(Lst_Index[1])
                Lst_Index[1] := 0
            
            if !Trim(Lst_Index[2])
                Lst_Index[2] := this.Length
            
            For i in XRange(Trim(Lst_Index[1]), Trim(Lst_Index[2]))
                Super[this.Init(i)] := Value
        }
    }
    
    Title()
    {
        Loop this.Length
            if Type(this[A_Index - 1]) == "String"
                this[A_Index - 1] := StrTitle(this[A_Index - 1])
    }
    
    Static SortMap(Map)
    {
        if Type(Map) !== "Map" && Type(Map) !== "Dict"
            Return "Illegal Input"
        
        Lst_Map := this.ListMap(Map)
        
        For i in XRange(0, Lst_Map.Length)
        {
            For j in XRange(0, Lst_Map.Length)
            {
                if Lst_Map[i][1] > Lst_Map[j][1]
                    Swap(i, j, Lst_Map)
            }
        }
        
        Return Lst_Map
    }
}

Class Math
{
    Static Pi := NTLCalc("pi")
    
    Static E := NTLCalc("e")
    
    Static Abs(Number)
    {
        Return NTLCalc("abs(" Number ")")
    }
    
    Static ACos(Number)
    {
        Return ACos(Number)
    }
    
    Static ASin(Number)
    {
        Return ASin(Number)
    }
    
    Static ATan(Number)
    {
        Return ATan(Number)
    }
    
    Static ATan2(CoordinateX, CoordinateY)
    {
        if CoordinateX > 0
            Return ATan(CoordinateY / CoordinateX)
        
        else if CoordinateX < 0
        {
            if CoordinateY < 0
                Return ATan(CoordinateY / CoordinateX) - Math.Pi
            
            else
                Return ATan(CoordinateY / CoordinateX) + Math.Pi
        }
        
        else
        {
            if CoordinateY > 0
                Return Math.Pi / 2
                
            else if CoordinateY < 0
                Return -Math.Pi / 2
            
            else
                Return "Undefined"
        }
    }
    
    Static Base(Text, Encoding, Target := 10)
    {
        Text := StrLower(Text)
        Lst_Base := [2, 8, 10, 16]
        
        if ListIn(Lst_Base, Encoding) == "Not Found" || ListIn(Lst_Base, Target) == "Not Found"
            Return Text
            
        if !ListCmp([Encoding, Target], [16, 10])
        {
            Map_Decode := Map()
            
            Loop 10
                Map_Decode[String(A_Index - 1)] := A_Index - 1
            
            Map_Decode["a"] := 10
            Map_Decode["b"] := 11
            Map_Decode["c"] := 12
            Map_Decode["d"] := 13
            Map_Decode["e"] := 14
            Map_Decode["f"] := 15
            Lst_Text := StrSplit(Text, "")
            Return_Num := 0
            
            For i in Lst_Text
                Return_Num += Math.Pow(16, Lst_Text.Length - A_Index) * Map_Decode[i]
            
            Return Return_Num
        }
        
        else if Encoding == 10
        {
            Text := Integer(Text)
            Return_Num := Math.ToBase(Text, Target)
            
            if Target == 2
            {
                Res := Return_Num
                
                Loop Mod(8 - Mod(StrLen(Res), 8), 8)
                    Return_Num := "0" Return_Num
            }
            
            Return Return_Num
        }
        
        else if !ListCmp([Encoding, Target], [2, 10])
        {
            Lst_Text := StrSplit(Text, "")
            Return_Num := 0
            
            For i in Lst_Text
                Return_Num += Math.Pow(2, Lst_Text.Length - A_Index) * i
            
            Return Return_Num
        }
        
        Return "Not Support."
    }
    
    Static Ceil(Number)
    {
        Return NTLCalc("ceil(" Number ")")
    }
    
    Static Cmp(Number1, Number2 := 0)
    {
        if Number1 < Number2
            Return -1
        
        else if Number1 == Number2
            Return 0
            
        else
            Return 1
    }
    
    Static Combination(Population, Individual)
    {
        Result := 1
        
        For j in XRange(0, Individual)
            Result := NTLCalc(Result "*" (Population - j) "/" (j + 1))
        
        Return Result
    }
    
    Static Cos(Number)
    {
        Return NTLCalc("cos(" Number ")")
    }
    
    Static Degrees(Number)
    {
        Return (Number / Math.Pi) * 180
    }
    
    Static Exp(Number)
    {
        Return NTLCalc("exp(" Number ")")
    }
    
    Static Factorial(Number)
    {
        a := List()
        temp := 0
        digit := 1
        i := 2
        j := 0
        a.Push(1)

        While i <= Number
        {
            num := 0
            
            While j < digit
            {
                temp := a[j] * i + num
                a[j] := Mod(temp, 10)
                num := temp // 10
                j++
            }
            
            j := 0
            
            While(num)
            {
                a.Push(Mod(num, 10))
                num //= 10
                digit++
            }
            
            i++
        }

        Loop a.Length
            Res .= a[-A_Index]

        Return Res
    }
    
    Static Floor(Number)
    {
        Return NTLCalc("floor(" Number ")")
    }
    
    Static Hypot(CoordinateX, CoordinateY)
    {
        Return NTLCalc("sqrt(" CoordinateX "*" CoordinateX "+" CoordinateY "*" CoordinateY ")")
    }
    
    Static Log(Number, Bottom := "e")
    {
        if Bottom == "e"
            Return NTLCalc("ln(" Number ")")
            
        else
            Return NTLCalc("log(" Number ")") / NTLCalc("log(" Bottom ")")
    }
    
    Static Log10(Number)
    {
        Return NTLCalc("log(" Number ")")
    }
    
    Static Max(Number*)
    {
        Lst_Number := Array()
        
        Loop Number.Length
        {
            if Type(Number[A_Index]) == "Array"
            {
                index := A_Index
                Loop Number[index].Length
                    Lst_Number.Push(Number[index][A_Index])
            }
            
            else
                Lst_Number.Push(Number[A_Index])
        }
        
        Number := StrReplace(ToString(Lst_Number), "[")
        Number := StrReplace(Number, "]")
        
        Return NTLCalc("max(" Number ")")
    }
    
    Static Min(Number*)
    {
        Lst_Number := Array()
        
        Loop Number.Length
        {
            if Type(Number[A_Index]) == "Array"
            {
                index := A_Index
                Loop Number[index].Length
                    Lst_Number.Push(Number[index][A_Index])
            }
            
            else
                Lst_Number.Push(Number[A_Index])
        }
        
        Number := StrReplace(ToString(Lst_Number), "[")
        Number := StrReplace(Number, "]")
        
        Return NTLCalc("min(" Number ")")
    }
    
    Static Modf(Number)
    {
        Sign := 1
        
        if Number < 0
            Sign := -1
        
        Abs_Number := NTLCalc("abs(" Number ")")
        Integer := NTLCalc("floor(" Abs_Number ")")
        
        Fraction := Abs_Number - Integer
        
        Return [Integer * Sign, Fraction * Sign]
    }
    
    Static Permutation(Population, Individual)
    {
        Result := 1
        
        For j in XRange(0, Individual)
            Result := NTLCalc(Result "*" (Population - j))
        
        Return Result
    }
    
    Static Pow(Number*)
    {   
        Pow_Result := Number[-1]
        
        Loop Number.Length - 1
            Pow_Result := Number[Number.Length - A_Index] ** Pow_Result
        
        Return Pow_Result
    }
    
    Static Radians(Number)
    {
        Return (Number / 180) * Math.Pi
    }
    
    Static Round(Number, N := 0)
    {
        Return NTLCalc("round(" Number "," N ")")
    }
    
    Static Sin(Number)
    {
        Return NTLCalc("sin(" Number ")")
    }
    
    Static Sqrt(Number)
    {
        Return NTLCalc("sqrt(" Number ")")
    }
    
    Static Tan(Number)
    {
        Return NTLCalc("tan(" Number ")")
    }
    
    Static ToBase(Text, Target)
    {
        Res := (Text < Target ? "" : Math.ToBase(Text // Target, Target)) . ((Modify := Mod(Text, Target)) < 10 ? Modify : Chr(Modify + 55))
        
        Return Res
    }
}

Class NTLCalc
{
    Static _ := DllCall("LoadLibrary", "Str", ntladd, "Ptr")
    
    Static Call(Exp)
    {
        Switch (DllCall("ntl\Calc", "AStr", Exp, "Ptr*", &Val := 0, 'cdecl'))
        {
            Case 0: Return StrGet(Val, "CP0")
            Case 1: Throw Error("ExpressionError")
            Case 2: Throw ValueError("ParamCountError")
            Case 3: Throw TypeError("TypeError")
            Case 4: Throw Error("UnknowTokenError")
            Case 5: Throw ZeroDivisionError("ZeroDivisionError")
        }
    }

    Static SetDebugMode(p := False)
    {
        DllCall("ntl\SetDebugMode", "Char", p, "cdecl")
    }

    Static SetOutputPrecision(p)
    {
        DllCall("ntl\SetOutputPrecision", "Int", p, "cdecl")
    }

    Static SetPrecision(p)
    {
        DllCall("ntl\SetPrecision", "Int", p, "cdecl")
    }
}

Class Random
{
    Static Choice(Number*)
    {
        Lst_Number := Array()
        
        Loop Number.Length
        {
            if Type(Number[A_Index]) == "Array"
            {
                index := A_Index
                Loop Number[index].Length
                    Lst_Number.Push(Number[index][A_Index])
            }
            
            else if Type(Number[A_Index]) == "List"
            {
                index := A_Index
                Loop Number[index].Length
                    Lst_Number.Push(Number[index][A_Index - 1])
            }
            
            else
                Lst_Number.Push(Number[A_Index])
        }
        
        Return Lst_Number[this.Random(1, Lst_Number.Length)]
    }
    
    Static Randn(Number)
    {
        Return List(BoxMuller(Number)*)
    }
    
    Static Random(A := 0, B := 1)
    {
        this.index := 624
        MT := List(0)
        MT.multiple(this.index)

        inter(t)
        {
            Res := 0xFFFFFFFF & t
            return Res
        }

        twister()
        {
            for i in xrange(624)
            {
                y := inter((MT[i] & 0x80000000) + (MT[Mod((i + 1), 624)] & 0x7fffffff))
                MT[i] := MT[Mod((i + 397), 624)] ^ y >> 1
                if Mod(y, 2) != 0
                    MT[i] := MT[i] ^ 0x9908b0df
            }
            this.index := 0
        }
            

        exnum()
        {
            if this.index >= 624
                twister()
            y := MT[this.index]
            y := y ^ y >> 11
            y := y ^ y << 7 & 2636928640
            y := y ^ y << 15 & 4022730752
            y := y ^ y >> 18
            this.index++
            return inter(y)
        }
            

        mainset(seed)
        {
            MT[0] := seed
            for i in xrange(1, 624)
                MT[i] := inter(Integer(1812433253 * (MT[i - 1] ^ MT[i - 1] >> 30) + i))
            return exnum()
        }
        
        if Type(A) == "Integer" && Type(B) == "Integer" && !(A == 0 && B == 1)
        {
            so := mainset(Time.Time()) / (2 ** 32 - 1)
            Rd := A + Integer((B - A) * so)
        }
        
        else
        {
            so := mainset(Time.Time() + Random(0, 100)) / (2 ** 32 - 1)
            Rd := A + (B - A) * so
        }
        
        Return Rd
    }
    
    Static RandRange(Stop, Start := 0, Step := 1, Swap := -1)
    {
        if Swap == -1 && Start
        {
            Temp := Stop
            Stop := Start
            Start := Temp
        }
    
        Lst_RandRange := Range(Start, Stop, Step)
        
        Return Lst_RandRange[this.Random(1, Lst_RandRange.Length)]
    }
    
    Static Shuffle(Lst_Number)
    {
        Loop Random.RandRange(Lst_Number.Length, 1, 1)
        {
            SwapX := Random.RandRange(Lst_Number.Length, 1, 1)
            SwapY := Random.RandRange(Lst_Number.Length, 1, 1)
            Swap(SwapX, SwapY, Lst_Number)
        }
        
        Return Lst_Number
    }
    
    Static Uniform(Stop, Start := 0, Swap := -1)
    {
        if Swap == -1
        {
            Temp := Stop
            Stop := Start
            Start := Temp
        }
        
        Random_Value := Random.Random()
        
        Return Start + (Stop - Start) * Random_Value
    }
}

Class Time
{
    Static Time()
    {
        Return DateDiff(A_Now, 19700101000000, "Seconds") - 28800
    }
}

Class XRange
{
    __New(Stop, Start := 0, Step := 1, Swap := -1)
    {
        if Swap == -1 && Start
        {
            this.Stop := Start
            this.Start := Stop
        }
        
        else
        {
            this.Stop := Stop
            this.Start := Start
        }
        
        this.Step := Step
        this.Loop_Times := Integer((this.Stop - 0.00000001 - this.Start) / Abs(this.Step)) + 1
        this.Index := this.Loop_Times
    }
    
   __Enum(Number)
    {
        this.Index := this.Loop_Times
        
        Return Fn
        
        Fn(&idx := 0, &value := 0)
        {
            if IsSet(value)
            {
                Try
                {
                    if this.Step < 0
                        idx := NTLCalc(this.Stop "-(" this.Loop_Times "-" this.Index ")*" this.Step)
                    
                    else
                        idx := NTLCalc("(" this.Loop_Times "-" this.Index ")*" this.Step "+" this.Start)
                    
                    Return this.Index-- > 0
                }
                
                Catch
                    Return 0
            }
            
            else
            {
                Try
                {
                    idx := Integer(this.Loop_Times - this.Index)
                    
                    if this.Step < 0
                        value := NTLCalc(this.Stop "-(" this.Loop_Times "-" this.Index ")*" this.Step)
                    
                    else
                        value := NTLCalc("(" this.Loop_Times "-" this.Index ")*" this.Step "+" this.Start)
                    
                    Return this.Index-- > 0
                }
                
                Catch
                    Return 0
            }
        }
    }
    
    Next()
    {
        if this.Index <= 0
            this.Index := this.Loop_Times
        
        if this.Step < 0
            value := NTLCalc(this.Stop "-(" this.Loop_Times "-" this.Index ")*" this.Step)
                    
        else
            value := NTLCalc("(" this.Loop_Times "-" this.Index ")*" this.Step "+" this.Start)
        
        this.Index--
        
        Return value
    }
}

Class Zip Extends List
{
    __New(Iter*)
    {
        min := -1
        
        For i in Iter
        {
            if min == -1
                min := Len(i)
            
            else if Len(i) < min
                min := Len(i)
        }
        
        Loop min
        {
            tmp := List()
            index := A_Index - 1
            Loop Len(Iter)
                tmp.append(Iter[A_Index][index])
            
            this.append(tmp)
        }
    }
}

BoxMuller(Number)
{
    Avg := 0
    Diff := 1
    Lst_y := []
    Pi := Math.PI
    
    Loop Number
    {
        A := Random.Random()
        B := Random.Random()
        y := Sqrt((-2) * Math.Log(A)) * Cos(2 * Pi * B) * Diff + Avg
        Lst_y.Push(y)
    }
    
    Return Lst_y
}

Dynloop_Loop(Data)
{
    Max_y_idx := Data.Length
    Row_max_idx := 1
    Arr_len := List()
    Lst_row := List()
    Lst_rst := List()
    Arr_idx := List(0)
    Arr_idx.multiple(Max_y_idx)

    For item in Data
    {
        _n := item.Length
        Arr_len.Append(_n)
        Lst_row.Extend(item)
        Row_max_idx *= _n
    }

    For row_idx in Range(0, Row_max_idx)
    {
        For y_idx in Range(0, Max_y_idx)
        {
            _pdt := 1
            
            For n in Range(y_idx + 1, Arr_len.Length)
                _pdt *= Arr_len[n]
            
            _offset := 0
            
            For n in Range(0, y_idx)
                _offset += Arr_len[n]
            
            Arr_idx[y_idx] := Mod((Row_idx // _pdt), Arr_len[y_idx]) + _offset
        }
        
        _lst_tmp := List()
        
        For idx in Arr_idx
            _lst_tmp.Append(Lst_row[idx])
        
        Lst_rst.Append(_lst_tmp)
    }

    Return Lst_rst
}

Len(Object)
{
    if Type(Object) == "String"
        Return StrLen(Object)
    
    else if ListIn(["Array", "List"], Type(Object)) !== "Not Found"
        Return Object.Length
    
    else if ListIn(["Dict", "Map"], Type(Object)) !== "Not Found"
        Return Object.Count
    
    else if Type(Object) == "ComObjArray"
        Return Object.MaxIndex + 1
    
    else if Type(Object) == "Counter"
        Return Object.Content.Count
    
    else if Type(Object) == "Numahk.NDArray"
        Return Object.array.Length
    
    else if Type(Object) == "Object"
        Return ObjOwnPropCount(Object)
}

ListCmp(Lst1, Lst2)
{
    Lst1 := ToString(Lst1)
    Lst2 := ToString(Lst2)
    
    if StrCompare(Lst1, Lst2) < 0
        Return -1
    
    else if StrCompare(Lst1, Lst2) > 0
        Return 1
    
    else
        Return 0
}

ListIn(Object, Part)
{
    if !IsObject(Object) && !IsObject(Part)
        Return InStr(Object, Part)
    
    else if Type(Object) == "Array"
    {
        For i in Object
        {
            if ToString(i) == ToString(Part)
                Return A_Index
        }
    }
    
    else if Type(Object) == "List"
    {
        For i in Object
        {
            if ToString(i) == ToString(Part)
                Return A_Index - 1
        }
    }
    
    else if Type(Object) == "Map" || Type(Object) == "Dict"
    {
        For i, Value in Object
        {
            if ToString(Value) == ToString(Part)
                Return "Key: " . i . "`nType: " . Type(i)
        }
    }
    
    else if Type(Object) == "Object" && Type(Part) == "Object"
        Return Hasbase(Object, Part)
    
    Return "Not Found"
}

Next(Iterator)
{
    Try
    {
        Res := Iterator.next()
        Return Res
    }
    
    Catch
        Return "Not A Iterator."
}

Range(Stop, Start := 0, Step := 1, Swap := -1)
{
    if Swap == -1 && Start
    {
        Temp := Stop
        Stop := Start
        Start := Temp
    }
    
    Lst_Range := List()
    Loop_Times := Integer((Stop - 0.00000001 - Start) / Abs(Step)) + 1
    
    if Start == Stop
        Loop_Times := 0
    
    NTLCalc.SetOutputPrecision(8)
    
    Loop Loop_Times
    {
        if Step < 0
            Lst_Range.Append(NTLCalc(Stop "-" A_Index "*" Step))
        
        else
            Lst_Range.Append(NTLCalc(Start "+(" A_Index "-" 1 ")*" Step))
    }
    
    Return Lst_Range
}

Swap(ValueX, ValueY, Object := "")
{
    if Type(Object) == "Array" || Type(Object) == "List" || Type(Object) == "Map" || Type(Object) == "Dict"
    {
        Temp := Object[ValueX]
        Object[ValueX] := Object[ValueY]
        Object[ValueY] := Temp
    }
    
    else
    {
        Try
        {
            Temp := %ValueX%
            %ValueX% := %ValueY%
            %ValueY% := Temp
        }
        
        Catch
            MsgBox("Swap Error`nTry to Input Object")
    }
}

ToString(Text)
{
    if Type(Text) == "Array"
    {
        if Text.Length < 1
            Text.InsertAt(1, "")
        
        String_Plus := ""
        String_Text := "[" . ToString(Text[1])
        
        Loop Text.Length - 1
            String_Plus .= "," . ToString(Text[A_Index + 1])
        
        String_Text .= String_Plus
        String_Text .= "]"
        
        Return String_Text
    }
    
    else if Type(Text) == "List"
    {
        if Text.Length < 1
            Text.InsertAt(1, "")
        
        String_Plus := ""
        String_Text := "[" . ToString(Text[0])
        
        Loop Text.Length - 1
            String_Plus .= "," . ToString(Text[A_Index])
        
        String_Text .= String_Plus
        String_Text .= "]"
        
        Return String_Text
    }
    
    else if Type(Text) == "ComObjArray"
    {
        if Text.MaxIndex() < 0
        {
            Text := ComObjArray(VT_VARIANT:=12, 1)
            Text[0] := ""
        }
        
        String_Plus := ""
        String_Text := "[" . ToString(Text[0])
        
        Loop Text.MaxIndex()
            String_Plus .= "," . ToString(Text[A_Index])
        
        String_Text .= String_Plus
        String_Text .= "]"
        
        Return String_Text
    }
    
    else if Type(Text) == "Numahk.NDArray"
    {
        if Text.array.Length < 1
            Text.array.InsertAt(1, "")
        
        String_Plus := ""
        String_Text := "[" . ToString(Text.array[0])
        
        Loop Text.array.Length - 1
            String_Plus .= "," . ToString(Text.array[A_Index])
        
        String_Text .= String_Plus
        String_Text .= "]"
        
        Return String_Text
    }
    
    else if Type(Text) == "Map" || Type(Text) == "Dict"
    {
        String_Text := "{"
        
        For i, Value in Text
            String_Text .= ToString(i) . ":" . ToString(Value) . ","
        
        if SubStr(String_Text, -1) !== "{"
            String_Text := SubStr(String_Text, 1, StrLen(String_Text) - 1)
        
        String_Text .= "}"
        
        Return String_Text
    }
    
    else if Type(Text) == "Integer" || Type(Text) == "Float" || Type(Text) == "String"
        Return String(Text)
    
    else if Type(Text) == "Object"
    {
        String_Text := "{"
        
        For i, Value in Text.OwnProps()
            String_Text .= ToString(i) . ":" . ToString(Value) . ","
        
        if SubStr(String_Text, -1) !== "{"
            String_Text := SubStr(String_Text, 1, StrLen(String_Text) - 1)
        
        String_Text .= "}"
        
        Return String_Text
    }
    
    else
        Return "#Null#"
}

建议添加的调试函数

Print

Print(Text*)
{
    Global Print_Gui
    Global Print_Edit
    Print_Text := ""
    Loop Text.Length
    {
        String_Text := ToStringPrint(Text[A_Index])
        
        if SubStr(String_Text, -1) == "," && (Type(Text[A_Index]) == "Array" || Type(Text[A_Index]) == "List" || Type(Text[A_Index]) == "ComObjArray" || Type(Text[A_Index]) == "Numpy.NDArray" || Type(Text[A_Index]) == "Map" || Type(Text[A_Index]) == "Dict" || Type(Text[A_Index]) == "Object")
            String_Text := SubStr(String_Text, 1, StrLen(String_Text) - 1)
        
        Print_Text .= String_Text "`n"
    }
    
    Print_Text := SubStr(Print_Text, 1, StrLen(Print_Text) - 1)
    
    if WinExist("Sinet Print")
    {
        WinActivate("Sinet Print")
        Print_Edit.Value .= "`n" Print_Text
        Return
    }
    
    Print_Gui := Gui()
    Print_Gui.Title := "Sinet Print"
    Print_Gui.BackColor := "87CEFA"
    Print_Edit := Print_Gui.Add("Edit", "R30 W800 ReadOnly")
    Print_Edit.SetFont("S12", "Arial")
    Print_Edit.Value := Print_Text
    Print_Gui.Show()
}

依赖函数ToStringPrint

ToStringPrint(Text)
{
    if Type(Text) == "Array"
    {
        if Text.Length < 1
            Text.InsertAt(1, "")
        
        String_Plus := ""
        String_Text := "[" . ToStringPrint(Text[1])
        
        Loop Text.Length - 1
            String_Plus .= "," . ToStringPrint(Text[A_Index + 1])
        
        String_Text .= String_Plus
        String_Text .= "]"
        
        Return String_Text
    }
    
    else if Type(Text) == "List"
    {
        if Text.Length < 1
            Text.InsertAt(1, "")
        
        String_Plus := ""
        String_Text := "[" . ToStringPrint(Text[0])
        
        Loop Text.Length - 1
            String_Plus .= "," . ToStringPrint(Text[A_Index])
        
        String_Text .= String_Plus
        String_Text .= "]"
        
        Return String_Text
    }
    
    else if Type(Text) == "ComObjArray"
    {
        if Text.MaxIndex() < 0
        {
            Text := ComObjArray(VT_VARIANT:=12, 1)
            Text[0] := ""
        }
        
        String_Plus := ""
        String_Text := "[" . ToStringPrint(Text[0])
        
        Loop Text.MaxIndex()
            String_Plus .= "," . ToStringPrint(Text[A_Index])
        
        String_Text .= String_Plus
        String_Text .= "]"
        
        Return String_Text
    }
    
    else if Type(Text) == "Numpy.NDArray"
    {
        if Text.array.Length < 1
            Text.array.InsertAt(1, "")
        
        String_Plus := ""
        String_Text := "[" . ToStringPrint(Text.array[0])
        
        Loop Text.array.Length - 1
            String_Plus .= "," . ToStringPrint(Text.array[A_Index])
        
        String_Text .= String_Plus
        String_Text .= "]"
        
        Return String_Text
    }
    
    else if Type(Text) == "Set"
        Return "Set(" ToStringPrint(Text.list) ")"
    
    else if Type(Text) == "Map" || Type(Text) == "Dict"
    {
        String_Text := "{"
        
        For i, Value in Text
            String_Text .= ToStringPrint(i) . ":" . ToStringPrint(Value) . ","
        
        if SubStr(String_Text, -1) !== "{"
            String_Text := SubStr(String_Text, 1, StrLen(String_Text) - 1)
        
        String_Text .= "}"
        
        Return String_Text
    }
    
    else if Type(Text) == "Pandas.DataFrame"
    {
        String_Text := " `t"
        
        For i in Text.Columns
            String_Text .= ToStringPrint(i) "`t"
        
        String_Text := SubStr(String_Text, 1, StrLen(String_Text) - 1)
        String_Text .= "`n"
        
        Loop Text.Index.Length
        {
            index := A_Index - 1
            String_Text .= ToStringPrint(Text.Index[index]) "`t"
            
            Loop Text.Data.array.Length
                String_Text .= ToStringPrint(Text.Data.array[A_Index - 1][index]) "`t"
            
            String_Text := SubStr(String_Text, 1, StrLen(String_Text) - 1)
            String_Text .= "`n"
        }
        
        Return String_Text
    }
    
    else if Type(Text) == "Integer"
        Return Text
    
    else if Type(Text) == "Float"
    {
        Sinet.NTLCalc.SetOutputPrecision(8)
        Sign := Text < 0
        Text := Sinet.NTLCalc(Abs(Text))
        
        if Text - Integer(Text) == 0
            Return Integer(Text)
        
        Loop 10 - StrLen(Text)
            Text .= "0"
        
        if Sign
            Text := "-" Text
        
        Return Text
    }
    
    else if Type(Text) == "String"
    {
        if isInteger(Text)
            Return Integer(Text)
        
        if isFloat(Text)
        {
            Sinet.NTLCalc.SetOutputPrecision(8)
            Sign := Text < 0
            Text := Sinet.NTLCalc(Abs(Text))
            if Text - Integer(Text) == 0
                Return Integer(Text)
        
            Loop 10 - StrLen(Text)
                Text .= "0"
        
            if Sign
                Text := "-" Text
            
            Return Text
        }
        
        Lst_Text := StrSplit(Text, "")
        
        Try
        {
            if Lst_Text[1] !== '"' || Lst_Text[-1] !== '"'
                Return '"' . Text . '"'
                
            else
                Return Text
        }
        
        Catch
            Return Text
    }
    
    else if Type(Text) == "Object"
    {
        String_Text := "{"
        
        For i, Value in Text.OwnProps()
            String_Text .= ToStringPrint(i) . ":" . ToStringPrint(Value) . ","
        
        if SubStr(String_Text, -1) !== "{"
            String_Text := SubStr(String_Text, 1, StrLen(String_Text) - 1)
        
        String_Text .= "},"
        
        Return String_Text
    }
    
    else if Type(Text) == "ListNode"
    {
        String_Text := "{val:"
        String_Text .= ToStringPrint(Text.val)
        String_Text .= "}"
        
        if Text.next
        {
            String_Text .= "->"
            String_Text .= ToStringPrint(Text.next)
        }
        
        Return String_Text
    }
    
    else
        Return "#Type: " Type(Text) "#"
}

ntl.dll下载

ntl.dll

提取码:mono复制
解压码:无

给TA捐赠
共{{data.count}}人
人已捐赠
其他教程案例

AHK Leetcode系列 61-70

2022-7-16 14:34:38

其他

飞鼠增强

2022-7-22 8:36:05

12 条回复 A文章作者 M管理员
  1. hexuren
    1河许人给您打赏了¥5
  2. hexuren

    建议专注于一个项目

    • 陌诺Mono

      Sinet那边暂时会放一放,移到这边,Leetcode那个还在写

    • 陌诺Mono

      Sinet的后期目标跟这个很像,算是迁移吧

    • 陌诺Mono

      主要是Sinet那边想不到要整啥了,那就把一个事情做的具体一点 这几个项目其实重叠性挺强的

  3. 蜜獾哥
    蜜獾哥给您打赏了¥5
  4. dbgba
    dbgba给您打赏了¥10
  5. dbgba
    dbgba给您打赏了¥2
  6. Arllk

    AHK能支持yolov5就好了

    • 陌诺Mono

      这种东西自己试着去搞,拿来主义大抵是要不到东西的

    • 陌诺Mono

      理论上所有东西ahk都可以支持,毕竟底核是VS2019的C++

  7.  17258

    666666666

个人中心
购物车
优惠劵
有新私信 私信列表
搜索