< User:Ahmetlii

define evaluate (expr)
set [TokenizeIter v] to [0] // Basic Tokenization Algorithm
set [TokenizeCollect v] to []
delete (all v) of [Tokens v]
repeat (length of (expr))
    change [TokenizeIter v] by (1)
    if <[symbols v] contains (letter (TokenizeIter) of (expr))> then
    if <(TokenizeCollect) = []> then
    set [TokenizeColllect v] to []
    else
    add (TokenizeCollect) to [Tokens v]
    set [TokenizeCollect v] to []
    end
    add (letter (TokenizeIter) of (expr)) to [Tokens v]
    else
    set [TokenizeCollect v] to (join (TokenizeCollect)(letter (TokenizeIter) of (expr))
    end
end
if <not <(TokenizeCollect) = []>> then
    add (TokenizeCollect) to [Tokens v]
    end
delete (all v) of [outputQueue v] // Shunting yard algorithm
delete (all v) of [operatorStack v]
repeat until <(length of [Tokens v]) < [1]>
    if <((item (1 v) of [Tokens v]) * (1)) = (item (1 v) of [Tokens v])> then
    add (item (1 v) of [Tokens v]) to [outputQueue v]
    delete (1 v) of [Tokens v]
    end
    else
    if <<<(item (1 v) of [Tokens v]) = [+]> or <(item (1 v) of [Tokens v]) = [-]>> or <<(item (1 v) of [Tokens  v]) = [*]> or <(item (1 v) of [Tokens v]) = [/]>>> then
    if <<(item (1 v) of [Tokens v]) = [+]> or <(item (1 v) of [Tokens v]) = [-]>> then 
    repeat until <<(length of [operatorStack v]) = [0]> or <(item (last v) of [operatorStack v])= [(]>>
    add (item (last v) of [operatorStack v]) to [outputQueue v]
    delete (last v) of [operatorStack v]
    end
    end
    if <<(item (1 v) of [Tokens v]) = [*]> or <(item (1 v) of [Tokens v]) = [/]>> then 
    repeat until <<<(item (last v) of [operatorStack v]) = [+]> or <(item (last v) of [Tokens v]) = [-]>> or <(lenght of [operatorStack v]) = [0]> or <(item (last v) of [operatorStack v]) = [)]>>>
    add (item (last v) of [operatorStack v]) to [outputQueue v]
    delete (last v) of [operatorStack v]
    end
    end
    add (item (1 v) of [Tokens v]) to [operatorStack v]
    delete (1 v) of [Tokens v]
    else
    if <(item (1 v) of [Tokens v]) = [(]> then
    add (item (1 v) of [Tokens v]) to [operatorStack v]
    delete (1 v) of [Tokens v]
    else
    repeat until <(item (last v) of [operatorStack v]) = [(]>
    add (item (last v) of [operatorStack v]) to [outputQueue v]
    delete (last v) of [operatorStack v]
    end
    delete (last v) of [operatorStack v]
    delete (1 v) of [Tokens v]
    end
    end
repeat until <(length of [operatorStack v]) = [0]>
    add (item (last v) of [operatorStack v]) to [outputQueue v]
    delete (last v) of [operatorStack v]
    end
delete (all v) of [stack v]
repeat until <(length of [outputQueue v]) = [0]> //Stack Machine
    if <(item (1 v) of [outputQueue v]) = [+]> then
    add ((item ((length of [stack v]) - [1]) of [stack v]) + (item (last v) of [stack v])) to [stack v]
    delete ((length of [stack v]) - [1]) of [stack v]
    end
    else
    if <(item (1 v) of [outputQueue v]) = [-]> then
    add ((item ((length of [stack v]) - [1]) of [stack v]) - (item (last v) of [stack v])) to [stack v]
    delete ((length of [stack v]) - [1]) of [stack v]
    end
    else
    if <(item (1 v) of [outputQueue v]) = [*]> then
    add ((item ((length of [stack v]) - [1]) of [stack v]) * (item (last v) of [stack v])) to [stack v]
    delete ((length of [stack v]) - [1]) of [stack v]
    end
    else
    if <(item (1 v) of [outputQueue v]) = [/]> then
    add ((item ((length of [stack v]) - [1]) of [stack v]) / (item (last v) of [stack v])) to [stack v]
    delete ((length of [stack v]) - [1]) of [stack v]
    end
    else
    add (item (1 v) of [outputQueue v]) to [stack v]
    end
    delete (1 v) of [outputQueue v]
    end
set [return v] to (item (1 v) of [stack v]) //Return Value