From 5438ae93121ef2f0b2b14ae1a35eddf3a4247a56 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Thu, 21 Mar 2024 16:20:26 -0400 Subject: [PATCH] Add a repeat function to type lisp. --- type_lisp.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/type_lisp.h b/type_lisp.h index ca2331f..b8e36bd 100644 --- a/type_lisp.h +++ b/type_lisp.h @@ -141,6 +141,27 @@ namespace Alepha::Hydrogen ::detail:: type_lisp_m { using type= TypeList< LeftArgs..., RightArgs... >; }; + + template< typename Item, std::size_t count > + struct repeat; + + namespace exports + { + template< typename Item, std::size_t count > + using repeat_t= typename repeat< Item, count >::type; + } + + template< typename Item, std::size_t count > + struct repeat + { + using type= cons_t< Item, repeat_t< Item, count - 1 > >; + }; + + template< typename Item > + struct repeat< Item, 0 > + { + using type= Nil; + }; } namespace Alepha::Hydrogen::inline exports::inline type_lisp_m