@name iterrecurse
@inputs 
@outputs 
@persist Stack:table
@trigger none

function number someFunc( N, Ret ) {
    if (N > 0) {
        local Test = someFunc( N - 1, Ret )

        Test--
        
        return Test    
    }
    
    return 0
}

function number someFuncLoop(N, Ret) {
    local RetVal = 0
    local Stack  = table()
    
    local Snapshot = array(
        N, #N
        0, #Test
        0  #Stage
    )    
    
    Stack:pushArray(Snapshot)
    
    while (Stack:count()) {
        local Pop = Stack:popArray()
        
        if (Pop[3, number] == 0) {
            if (Pop[1, number] > 0) {
                Pop[3, number] = 1
                Stack:pushArray(Pop)
                
                local Snapshot = array(
                    Pop[1, number] - 1, #N
                    0, #Test
                    0  #Stage
                )
                
                Stack:pushArray(Snapshot)
                continue
            }
            
            RetVal = 0

            continue
        }
        elseif (Pop[3, number] == 1) {
            Pop[2, number] = RetVal
            Pop[2, number] = Pop[2, number] - 1
            
            RetVal = Pop[2, number]
            
            continue   
        }
    }
    
    return RetVal 
}

print( someFunc( 5, 0 ) )
print( someFuncLoop( 5, 0 ) )
#[

         

    function number negamax( G:table, Depth, Turn ) {
        if (Depth == 0) { 
            return eval(G)*Turn
        }
        
        local Score = -10000
        local Best  = 0
        
        for (Column = 1, 7) {
            local Row = 6
            for (R = 1, Row) {
                if (G[R, array][Column, number] != 0) {
                    Row--
                    break    
                }
            }
            
            if (Row > 0) {
                G[Row - 1, array][Column, number] = Turn
                
                local Value = -negamax(G, Depth - 1, -Turn)
                if (Score < Value) {
                    Score = Value
                    Best = Column 
                }
                
                G[Row - 1, array][Column, number] = 0   
            }
        }
        
        BestCol = Best
    
        return Score  
    }
]#

