rpn_compute symbols theTime (RpnStack xs)       = num 

  where
    (Number num) = head . foldl evaluate [] $ xs

    -- evaluate unary function (sin, cos, ..)
    evaluate ((Number x):ys) (UnaFunc f) = 
      (Number $ f x):ys

    -- evaluate binary function (*,+,..)
    evaluate ((Number x):(Number y):ys) (BinFunc f) =
      (Number $ f y x):ys

    -- extract current time
    evaluate ys (Time) = (Number theTime):ys

    -- extract molecule variable
    evaluate ys (Variable x) = 
      (Number $ get_val_from_symbolTable x theTime symbols):ys 

    evaluate ys item = item:ys


-- | retrieve the value of a given symbol (either variable or molecule count) from
-- the symbol table 
rpn_compute symbols theTime (RpnStack xs)       = num 

  where
    (Number num) = head . foldl evaluate [] $ xs

    -- evaluate unary function (sin, cos, ..)
    evaluate ((Number x):ys) (UnaFunc f) = 
      (Number $ f x):ys

    -- evaluate binary function (*,+,..)
    evaluate ((Number x):(Number y):ys) (BinFunc f) =
      (Number $ f y x):ys

    -- extract current time
    evaluate ys (Time) = (Number theTime):ys

    -- extract molecule variable
    evaluate ys (Variable x) = 
      (Number $ get_val_from_symbolTable x theTime symbols):ys 

    evaluate ys item = item:ys


-- | retrieve the value of a given symbol (either variable or molecule count) from
-- the symbol table 
rpn_compute symbols theTime (RpnStack xs)       = num 

  where
    (Number num) = head . foldl evaluate [] $ xs

    -- evaluate unary function (sin, cos, ..)
    evaluate ((Number x):ys) (UnaFunc f) = 
      (Number $ f x):ys

    -- evaluate binary function (*,+,..)
    evaluate ((Number x):(Number y):ys) (BinFunc f) =
      (Number $ f y x):ys

    -- extract current time
    evaluate ys (Time) = (Number theTime):ys

    -- extract molecule variable
    evaluate ys (Variable x) = 
      (Number $ get_val_from_symbolTable x theTime symbols):ys 

    evaluate ys item = item:ys


-- | retrieve the value of a given symbol (either variable or molecule count) from
-- the symbol table 