Functional Data Structures — Stacks

Thobias Larsen
7 min readJul 15, 2024

In this article, I will be demonstrating how to implement a classical data structure, the stack, using a functional programming language. In this article, I will be using F# for the demonstration. The goal is to understand how functional programming offers a different perspective on data structures and how to work with them.

A stack of donuts — visualization idea of a stack

Prerequisites

For this article, I will be making assumptions that you already should know what a stack is and have a basic idea or understanding of how it works in an object-oriented language. I do however not expect you to understand anything about F# or how functional programming works. I will be demonstrating and explaining all the necessary new syntax and ideas as we progress.

“Functional programming offers a different perspective and way of thinking about code and how to solve problems. In functional programming, everything revolves around 2 things, types, and functions.”

What's the deal with functional programming?

Functional programming offers a different perspective and way of thinking about code and how to solve problems. In functional programming, everything revolves around 2 things…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account?

Thobias Larsen
Thobias Larsen

Written by Thobias Larsen

I am a 22-year-old Computer Science student. I love nature, computers, and expressing my thoughts and ideas through text or speech.

No responses yet

What are your thoughts?