Open In App

Introduction to LISP

Last Updated : 17 Mar, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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 second-oldest high-level programming language in the world which is invented by John McCarthy in the year 1958 at the Massachusetts Institute of Technology.

Features of  LISP Programming Language:

  1. It is a machine-independent language
  2. It uses iterative design methodology and is easily extensible
  3. It allows us to create and update the programs and applications dynamically.
  4. It provides high-level debugging.
  5. It supports object-oriented programming.
  6. It supports all kinds of data types like objects, structures, lists, vectors, adjustable arrays, set, trees,hash-tables, and symbols.
  7. It is an expression-based language
  8. It can support different decision-making statements like if, when,case, and cond
  9. It will also support different iterating statements like do, loop,loopfor, dotimes and dolist.
  10. It will support input and output functions
  11. By using lisp we can also create our own functions

These are the features of LISP Programming.

Hello World program in LISP:

we can start writing  a string by using the write-line method

Syntax:

(write-line string)

Example:

Lisp




;this is a comment
(write-line "Hello Geeks")


Output:

Hello Geeks

Naming Conventions:

The naming Conventions mean the way we are declaring variables in a program. It includes the variable names and syntax formats

Lets us discuss the conventions

  • A variable can contain  any number of alphanumeric characters other than whitespace, open and  closing parentheses

Example:

Acceptable – hello,saisravan, etc

Not Acceptable – hell()0,sat{ sravab{,,,,,,,,etc

  • A variable can not contain double and single quotes, backslash, comma, colon, semicolon, and vertical bar.

Example:

Acceptable – hello,saisravan, etc

Not Acceptable – hell””)0,sat//*& sra//>vab{,,,,,,,,etc

  • A variable can not start with a digit but. it can contain any number of digits

Example:

Acceptable – hello88Geeks, r56lisp, ,,,,,etc

Not Acceptable – 40geeks,4klll,….etc

Example Code: For acceptable names

Lisp




;acceptable naming conventions
(write-line "hello")
 
(terpri)
 
;acceptable naming conventions
(write-line "hello99")
 
(terpri)
 
;acceptable naming conventions
(write-line "hello geeks")
 
(terpri)
 
;acceptable naming conventions
(write-line "hello_Geek")
 
(terpri)
 
;acceptable naming conventions
(write-line "hello123")


 Output:

hello
hello99
hello geeks
hello_Geek
hello123


Similar Reads

Constants in LISP
In LISP all constants are global variables. Values of constant never change throughout the execution of the program. Defining constant in LISP: New global constants are defined using the DEFCONSTANT construct Syntax: (defconstant name initial-value-form "documentation-string") Example: Let's create a global constant whose value will contain the rat
2 min read
Dotimes Construct in LISP
In this article, we will discuss the dotimes loop in LISP. The dotimes is a looping statement used to iterate the elements. Unlike other looping constructs, it only loops for a specified number of iterations. Syntax: (dotimes (n range) statements --------------- -------------- ) where, n is the starting number-0The range is the last number till tha
1 min read
LISP - Comparison Operators on Characters & Strings
The contents of a field are compared to the contents of another field or a constant using Comparison operators. In Simple words, comparator operators are used to compare whether the two or more different values are equal or not. Comparison Operators on Character: Characters are not supported by numerical comparison functions and operators such as
3 min read
Logical Operators in LISP
Common LISP supports 3 types of logical operators on Boolean Values. The arguments of these operators are evaluated conditionally, therefore they are also part of the LISP control Structure. The common LISP operators are listed below in the table: OperatorSyntaxDescriptionandand number1 number2This operator takes two numbers which are evaluated lef
2 min read
Input & Output in LISP
Pre-requisites: Introduction to LISP Lisp provides a huge set of facilities for performing input/output. All the input/output operations are performed on streams of several kinds. While reading and writing binary data is possible, the majority of Common Lisp input/output methods read or write characters. For reading and writing individual character
10 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 parameter it should be supplied with one individu
3 min read
Basic Syntax in LISP
LISP is a list processing programming language. It is widely used in the manipulation of data strings. It provides an input and output library. LISP provides a macro system and provides well control structures for the manipulation of data. Basic Blocks in LISP:There are three basic building blocks of the LISP program: AtomListStringAtom: An atom in
2 min read
Program Structure in LISP
The expressions we use in Lisp are known as the s-expressions which are composed of atoms, strings, and lists. An s-expression is itself a valid program. REPL:REPL is an acronym for Read Evaluate Print Loop. In the case of an interpreter, the program is read, checked for errors in loops, and the value is returned by the program. Lisp program can ru
2 min read
Strings in LISP
A string is a set of characters. String are enclosed in double-quotes. Example: "hello geek","java","python" etc Example: LISP program to display strings C/C++ Code ;edisplay hello geek (write-line "Hello Geek") ;display (write-line "Welcome to java") Output: Hello Geek Welcome to javaString Comparison Functions: Used to compare
4 min read
Comparison Operators in LISP
In this article, we will discuss the comparison operators in LISP. These operators are used to compare numbers by taking two or more operands. Note: This will work only on numbers, Different comparison operators are:OperatorSyntaxNameDescription== operand1 operand2equal toThis operator checks if the values of the operands are all equal or not, if y
4 min read
Article Tags :