summaryrefslogtreecommitdiff
path: root/tiger-compiler/lib/misc/list.hh
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
commit967be9e750221ab2ab783f95df79bb26d290a45e (patch)
tree6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/lib/misc/list.hh
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/lib/misc/list.hh')
-rw-r--r--tiger-compiler/lib/misc/list.hh25
1 files changed, 25 insertions, 0 deletions
diff --git a/tiger-compiler/lib/misc/list.hh b/tiger-compiler/lib/misc/list.hh
new file mode 100644
index 0000000..d27ab66
--- /dev/null
+++ b/tiger-compiler/lib/misc/list.hh
@@ -0,0 +1,25 @@
+/**
+ ** \file misc/list.hh
+ ** \brief Declaration of misc::list
+ */
+
+#pragma once
+
+#include <misc/vector.hh>
+
+/// Wrappers on misc::vectors to provide functional-style list manipulation.
+namespace misc::list
+{
+ /// Build a list of a \a head and a \a tail.
+ template <typename T> vector<T> cons(const T head, const vector<T>& tail);
+
+ /// Get the head and tail of the list. Invert of cons.
+ template <typename T> std::pair<T, vector<T>> snoc(const vector<T>& v);
+
+ /// Decompose the list into an array to use structured bindings.
+ template <std::size_t Size, typename T>
+ std::array<T, Size> decompose(const vector<T>& v);
+
+} // namespace misc::list
+
+#include <misc/list.hxx>