summaryrefslogtreecommitdiff
path: root/tigrou/linked-list/linked-list.tih
diff options
context:
space:
mode:
Diffstat (limited to 'tigrou/linked-list/linked-list.tih')
-rw-r--r--tigrou/linked-list/linked-list.tih15
1 files changed, 15 insertions, 0 deletions
diff --git a/tigrou/linked-list/linked-list.tih b/tigrou/linked-list/linked-list.tih
new file mode 100644
index 0000000..b890f3a
--- /dev/null
+++ b/tigrou/linked-list/linked-list.tih
@@ -0,0 +1,15 @@
+type node = {value : int, next : node}
+function append(list: node, element: int) =
+ if list.next = nil then
+ list.next := node{value = element, next = nil}
+ else
+ append(list.next, element)
+
+function display(list: node) =
+ if list <> nil then
+ (
+ print_int(list.value);
+ (if list.next <> nil then
+ print(" -> "));
+ display(list.next)
+ )