Lisp (used to be called LISP) is a programming language. It is among the oldest programming languages that are still used today. Only Fortran is one year older. Lisp was designed by John McCarthy in 1958. The best-known versions of LISP are Common Lisp, Scheme and Clojure. Many concepts that are used in modern programming languages were first created in Lisp. Linked lists are a very important data structure in Lisp. The basic concepts behind Lisp are easy to learn. Logo is another version of Lisp that was made for children. Logo can help young children develop skills and become efficient within the programming language.
Simple examples (Scheme) Edit
In Lisp, operations are written in prefix notation, and they start and end with parentheses. For example, the formula {\displaystyle {\frac {3+5}{4}}}{\displaystyle {\frac {3+5}{4}}} is written as:
(/ (+ 3 5) 4)
; returns 2
Because Lisp is a functional language, Lisp programs often use recursion to solve problems. Here is a Scheme program that finds the factorial of a number. The function (factorial n) starts by testing if {\displaystyle n=0}{\displaystyle n=0} or not. If {\displaystyle n=0}{\displaystyle n=0}, then (factorial 0) is 1. If {\displaystyle n\neq 0}{\displaystyle n\neq 0}, then (factorial n) returns the product of {\displaystyle n}n and the factorial of {\displaystyle n-1}{\displaystyle n-1}.
(define (factorial n)
(if
(= n 0)
1
(* n (factorial (- n 1)))))
(factorial 6)
; returns the factorial of 6: 6! = 6*5*4*3*2*1 = 720
Linked lists are an important idea in Lisp. The list without any things in it is known as the empty or nil list, and is written as '(). A list that has things in it is written as '(dog cat).
The operation car is used to get the first thing of a list. For example,
(car '(dog cat fish))
; returns 'dog, which is the first thing in the list
(car '(1 2 3 4 5 6 7))
; returns 1
(car '())
; this code gives an error because the list is empty/nil
The operation cdr returns everything in the list except for the first thing.
(cdr '(dog cat fish))
; returns '(cat fish)
(cdr '(6))
; returns '(), because there is nothing in the list after the first thing (6)
(cdr '())
; gives an error because the list is empty/nil
Here is a hello world program in Scheme:
(display "Hello world!")
Simple examples (Scheme) Edit
In Lisp, operations are written in prefix notation, and they start and end with parentheses. For example, the formula {\displaystyle {\frac {3+5}{4}}}{\displaystyle {\frac {3+5}{4}}} is written as:
(/ (+ 3 5) 4)
; returns 2
Because Lisp is a functional language, Lisp programs often use recursion to solve problems. Here is a Scheme program that finds the factorial of a number. The function (factorial n) starts by testing if {\displaystyle n=0}{\displaystyle n=0} or not. If {\displaystyle n=0}{\displaystyle n=0}, then (factorial 0) is 1. If {\displaystyle n\neq 0}{\displaystyle n\neq 0}, then (factorial n) returns the product of {\displaystyle n}n and the factorial of {\displaystyle n-1}{\displaystyle n-1}.
(define (factorial n)
(if
(= n 0)
1
(* n (factorial (- n 1)))))
(factorial 6)
; returns the factorial of 6: 6! = 6*5*4*3*2*1 = 720
Linked lists are an important idea in Lisp. The list without any things in it is known as the empty or nil list, and is written as '(). A list that has things in it is written as '(dog cat).
The operation car is used to get the first thing of a list. For example,
(car '(dog cat fish))
; returns 'dog, which is the first thing in the list
(car '(1 2 3 4 5 6 7))
; returns 1
(car '())
; this code gives an error because the list is empty/nil
The operation cdr returns everything in the list except for the first thing.
(cdr '(dog cat fish))
; returns '(cat fish)
(cdr '(6))
; returns '(), because there is nothing in the list after the first thing (6)
(cdr '())
; gives an error because the list is empty/nil
Here is a hello world program in Scheme:
(display "Hello world!")
Similar Readings (5 items)
Top Programming Languages
Why PHP continues to be a popular but divisive programming language
Ruby (programming language)
Why Rust is the most admired language among developers
Computer program - simple wikipedia
Summary
Lisp, one of the oldest and still-used programming languages, was designed by John McCarthy in 1958. Known versions include Common Lisp, Scheme, and Clojure. Originally designed for children as Logo, it introduced several concepts used in modern programming languages. Operations are written in
Statistics
395
Words1
Read CountDetails
ID: 61d6cfe2-4e6c-464b-ba0a-375235ed5dbd
Category ID:
URL: https://simple.m.wikipedia.org/wiki/Lisp_(programming_language)
Created: 2022/01/06 20:17
Updated: 2025/12/09 18:20
Last Read: 2022/01/06 20:22