What algorithm does Excel use to recalculate formulas?

前端 未结 3 1929
萌比男神i
萌比男神i 2021-01-15 16:08

Are the formulas represented in a syntax tree then recalculated using a design pattern like the Visitor pattern? How would you go about reproducing the recalculation process

3条回答
  •  清歌不尽
    2021-01-15 16:53

    Are the formulas represented in an AST then recalculated using a design pattern like the Visitor pattern?

    You're thinking interpreter, not visitor. While treewalking using a visitor can be employed in conjunction with interpretation, employing an interpreter makes more sense here (hence the name). What this does is basically what friol wrote, i.e. traverse the tree in post-order and execute the function associated with each node.

提交回复
热议问题