![]() |
VOOZH | about |
Macro is similar to a function in popular languages like C++, java, etc. that takes arguments and returns a LISP form to be evaluated. It is useful when the same code has to be executed with a few variable changes.
For example, rather than writing the same code for squaring a number, we can define a macro that holds the code for squaring.
To define a named macro in LISP, a default macro - defmacro is used.
Syntax:
(defmacro macroName (parameters) expressions )
Where,
Output:
Hello everyone GfG Hello everyone Welcome "GfG audience" Welcome "Awesome people" 7 + 18 : 25 Square of 5 is 25