Snippets tagged stack

  • Seq.reduceBallanced function

    The function has the same type as Seq.reduce. Instead of reducing elements from the left to the right, it splits the input into two halves, reduces each half separately and then aggregates the results using the given function. This means that the values are aggregated into a ballanced tree, which can save stack space.

    2 people like this

    Posted: 13 years ago by Tomas Petricek

  • Implementation of Immutable Stack

    Immutable stack can be implemented via Discriminated Union Type with methods like Push and Pop. The following snippet is a simple version of it.

    2 people like this

    Posted: 12 years ago by Joel Huang