I get part of a macro name as an argument. I want to use that to form a complete macro name and invoke it. How can I do that?
Here is a test case to demonstrate what I am trying to achieve:
\documentclass{article}
\newcommand{\typeapple}{fruit}
\newcommand{\typecar}{vehicle}
\newcommand{\typeeagle}{bird}
\newcommand{\printtype}[1]{\type#1} % Help me implement this \printtype macro.
\begin{document}
Type of apple is: \printtype{apple}.
Type of car is: \printtype{car}.
Type of eagle is: \printtype{eagle}.
\end{document}
I need to implement \printtype macro such that it takes one argument, adds \type as a prefix to that argument and then invoke the resulting macro name. For example if we call \printtype{apple}, it should add \type to apple to obtain \typeapple and then invoke \typeapple.
Can this be done?

etoolbox(can be done without it). Have\printtyperun\csuse{type#1}. Note I would not use\newcommand{\typeapple}{fruit}but rather use\DeclareType{apple}{fruit}and internally it would use\csdef{ll-#1}{#2}and then alter\printtype{apple}to run\csuse{ll-#1}. Thell-is to saveguard against\csdefoverwriting something important. – daleif May 25 '21 at 10:27