Optional Parameters in LISP Last Updated : 15 Nov, 2021 Comments Improve Suggest changes Like Article Like Report Optional Parameters are the parameters that are optional in the function. We can put optional parameters whenever the arguments are not necessary. If we keep the optional parameters in a function and pass the values, then the values are taken in place of optional parameters. If values are not passed, then optional parameters will take NIL and return NIL. If we want to put optional parameters as arguments, then put &optional before the names of the optional parameters. Function Syntax: (defun function_name (parameter1,parameter2,.......,parameter n.... &optional ) other statements)) (call function value1,value2,.,value n, optional values) Example: LISP program to display all its passed parameters. Lisp ;create a function named display ;pass the 2 parameters and optional as three parameters (defun display (val1 val2 &optional op1 op2 op3) (write (list val1 val2 op1 op2 op3))) ;pass the all values (display 10 20 30 40 50) (terpri) ;pass only two values (display 10 20 ) (terpri) ;pass only three values (display 10 20 30) (terpri) ;pass only four values (display 10 20 30 40) (terpri) Output: (10 20 30 40 50) (10 20 NIL NIL NIL) (10 20 30 NIL NIL) (10 20 30 40 NIL) Example 2: LISP Program to get the sum of numbers Lisp ;create a function named sum ;pass the 2 parameters and optional as three parameters (defun sum (val1 val2 &optional op1 op2 op3) (write ( + val1 val2 op1 op2 op3))) ;pass the all values to get sum (sum 10 20 30 40 50) (terpri) Output: 150 Comment More infoAdvertise with us Next Article Optional Parameters in LISP D deepakresearch222 Follow Improve Article Tags : LISP LISP-Basics LISP-Functions Similar Reads Rest Parameters in LISP LISP Function's parameters list has a basic aim of declaring the variables which will receive the arguments that are passed in the function. Normally parameter list contains a basic list of variable names, those parameters are called "required parameters". If a function is called, for every required 3 min read How to define Optional Parameter in Scala? Optional parameters in Scala provide us with a procedure or a way to define some default values for function parameters. The need to define default values comes when a value is not provided for the parameter during function invocation. These are also useful when we want to provide some default or sp 5 min read Keyword Parameters in LISP LISP Function's parameters list has a basic aim of declaring the variables which will receive the arguments that are passed in the function. Normally parameter list contains a basic list of variable names, those parameters are called "required parameters". If a function is called, for every required 3 min read Operators in LISP Operators are the foundation of any programming language. Thus the functionality of the LISP programming language is incomplete without the use of operators. We can define operators as symbols that help us to perform specific mathematical and logical computations on operands. In other words, we can 5 min read Predicates in LISP In this article, we will discuss predicates. Predicates are similar to functions that will be used to test their arguments for conditions. They will return NIL if the conditions are not met, if the conditions are met, they will return T. Types of predicates: Below is a list of major Predicates with 5 min read Like