diff --git a/list.cpp b/list.cpp new file mode 100644 index 0000000..8c671a1 --- /dev/null +++ b/list.cpp @@ -0,0 +1,40 @@ +/* list.cpp + * Date: 2021-11-20 + * Author: Aryadev Chavali + */ + +#include +#include + +template +struct List +{ + T value; + struct List *next; +}; + +template +struct List *append(struct List *lst, T value) +{ + struct List *node; + if (lst == NULL) + { + node = new List; + node->value = value; + node->next = NULL; + return node; + } + + for (node = lst; node->next != NULL; node = node->next) + continue; + + node->next = new List; + node->next->value = value; + node->next->next = NULL; + return lst; +} + +int main(void) +{ + return 0; +}