"Whereas some declarative programmers only pay lip service to equational reasoning, users of functional languages exploit them every time they run a compiler, whether they notice it or not." | ||
-- Philip Wadler, How to Declare an Imperative |
In the last chapter, we delved into the ubiquitous IEnumerable <T>
and sequence type (Seq <T>
) which is the alias for it. In this chapter, we shift our focus to another essential data structure, the stack
. Stacks, heaps, hash tables, and linked lists are some of the fundamental data structures used in everyday development. In this chapter, we will gain knowledge about stacks by building one as a custom Abstract Data Type (ADT), which is outside the F# core library. Having an in-depth understanding of stack will prepare you for further, more advanced implementations. We will explore the operations which our implementation requires, necessary test cases, and finally, simple algorithms using stacks, such as converting...