From f922e0b5dfc0a03378b231ad2705dbef29310d56 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 16 Jan 2015 23:55:01 +0100 Subject: Implemented recursive `Concatenate` _Cons_ constructor * concatenates two given _Cons_ based lists into a single one --- src/list/list.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/list/list.h') diff --git a/src/list/list.h b/src/list/list.h index 47d0d2f..edd46e8 100644 --- a/src/list/list.h +++ b/src/list/list.h @@ -21,6 +21,31 @@ struct List { typedef Cons type; }; +template +using Head = Car; + +template +using Tail = Cdr; + +template < + typename Primary, + typename Secondary +> +struct Concatenate { + typedef Cons< + Head, + typename Concatenate< + Tail, + Secondary + >::type + > type; +}; + +template +struct Concatenate { + typedef Secondary type; +}; + } #endif // TYPEASVALUE_SRC_LIST_LIST_H_ -- cgit v1.2.3