Mapping Functions in LISP Last Updated : 09 Feb, 2022 Comments Improve Suggest changes Like Article Like Report In this article, we will discuss mapping functions in lisp. Mapping functions are applied on the list data structure for combining one or more lists of elements. By using this we can perform mathematical operations and can join the elements. The main advantage of this function is that we can combine two or more lists with different sizes. we can also use these functions in our user-defined functions Syntax: mapcar operation list1 list2 ..........list n where, mapcar is the keyword to map the listsoperation is used to perform two or more listslists are the input lists to be mapped Example 1: Lisp program to map the list by adding 1 to all the numbers in the list. Lisp ;add the number 1 to all the numbers in the list and ;display (write (mapcar '1+ '(1 2 3 4 5))) Output: (2 3 4 5 6) Example 2: Perform squaring and cubing of numbers Lisp ;function to square all the elements by mapping the elements ( defun squaredata(data) (mapcar #'(lambda(i) (* i i )) data) ) ; function to cube all the elements by mapping the elements ( defun cubedata(data) (mapcar #'(lambda(i) (* i i i )) data) ) ;call the square function (write (squaredata '(1 2 3 4 5))) ;call the cube function (write (cubedata '(1 2 3 4 5))) Output: (1 4 9 16 25)(1 8 27 64 125) Example 3: Program to map two lists by performing arithmetic operations Lisp ;map lists by performing addition (write (mapcar '+ '(1 2 3 4 5) '( 5 7 8 3 2))) (terpri) ;map lists by performing subtraction (write (mapcar '- '(1 2 3 4 5) '( 5 7 8 3 2))) (terpri) ;map lists by performing multiplication (write (mapcar '* '(1 2 3 4 5) '( 5 7 8 3 2))) (terpri) ;map lists by performing division (write (mapcar '/ '(1 2 3 4 5) '( 5 7 8 3 2))) (terpri) Output: (6 9 11 7 7) (-4 -5 -5 1 3) (5 14 24 12 10) (1/5 2/7 3/8 4/3 5/2) Comment More infoAdvertise with us Next Article Mapping Functions in LISP S saisravanprojects Follow Improve Article Tags : LISP LISP-Basics LISP-DataTypes Similar Reads Functions in LISP A function is a set of statements that takes some input, performs some tasks, and produces the result. Through functions, we can split up a huge task into many smaller functions. They also help in avoiding the repetition of code as we can call the same function for different inputs. Defining Functio 3 min read Output Functions in LISP Output functions need an optional argument known as output stream which by default is "output-stream" and can be assigned to another stream where the output has to be sent. Write:write object  key : stream Example 1: Lisp ; LISP program for Write (write "Hello World") (write "To") (write "The") (wr 3 min read Naming Conventions in LISP LISP is a programming language that has an overall style that is organized around expressions and functions. Every Lisp procedure is a function, and when called, it returns a data object as its value. It is also commonly referred to as âfunctionsâ even though they may have side effects. Lisp is the 2 min read Returning Values Functions in LISP In the previous article on the LISP function, we have seen the syntax of defining a function and calling the function by passing some arguments. Returning values from a function: In LISP, whatever is the last expression in the body of a function becomes the return value of that function. Example: Le 2 min read map() Function in R In R Programming Language the Map function is a very useful function used for element-wise operations across vectors or lists. This article will help show how to use it with multiple code examples. Map Function in RThe Map function in R belongs to the family of apply functions, designed to make oper 3 min read Like