We are still actively working on the spam issue.

Difference between revisions of "Lisp"

From InstallGentoo Wiki
Jump to: navigation, search
m (Lambda)
(Important Concepts)
Line 34: Line 34:
 
==== FEXPRs ====
 
==== FEXPRs ====
 
=== Scoping ===
 
=== Scoping ===
 +
=== Functions ===
  
 
==Dialects==
 
==Dialects==

Revision as of 07:08, 13 June 2014

Lisp is a programming language originally created by John McCarthy in 1958. Despite its age, it is still a popular choice for modern programmers. Lisp has proven itself flexible enough to evolve to meet the needs of modern programmers. Modern implementations often come "batteries-included", meaning that the programmer has access to powerful libraries for databases, regular expressions, networking, and more.

Lisp comes in different dialects, which are divided into different implementations. Three important dialects are Common Lisp, Emacs Lisp, and Scheme.

Important Concepts

Symbols

Lists

Lambda

In most Lisps and functional languages Lambda is the constructor of un-named or anonymous procedures and functions.

(defun double-list-elements (l)
  (mapcar (lambda (n)
            (* n 2))
          l))

In this example the anonymous procedure, or lambda form, multiplies its argument by two. The procedure it is contained in uses MAPCAR to apply it to each element of the list it is given, and returns a list of results:

> (double-list-elements '(1 2 3 4 5 6 7 8 9 10))
(2 4 6 8 10 12 14 16 18 20)

Its use by itself can be observed as such:

> ((lambda (n) (* n 2)) 5)
10

Higher Order Procedures

Recursion

Natural Recursion

Proper Tail Recursion

Homoiconicity

Macros

Compile-time Macros

Read Macros

FEXPRs

Scoping

Functions

Dialects

Common Lisp

Common Lisp was designed by Scott Fahlman, Richard P. Gabriel, David Moon, Guy L. Steele, and Dan Weinreb, and is described in CLTL2, as well as the Common Lisp Hyperspec.

Popular implementations include Steel Bank Common Lisp, GNU Clisp, ClozureCL, and ECL.

Emacs Lisp

Emacs Lisp (Elisp) is used to program and extend Emacs. Programmers who either use or are interested in using Emacs should learn Elisp.

A very good tutorial, as well as primary langugage documentation for Elisp is available from directly within Emacs. The introduction can by found by pressing C-h i then typing mEmacs Lisp Intro and pressing Return, and the language documentation can be found by typing mElisp instead.

Scheme

Scheme, created by Guy L. Steele and Gerald Jay Sussman, is the dialect used in SICP.

Two of the most popular implementations are Chicken and GNU Guile, both of which are embeddable, and include a well-designed C API, and an FFI for interfacing with C libraries.

Niche Lisps

System scripting
  • newLISP
  • scsh
  • LUSH
CUDA & OpenCL
  • Harlan
Programming language research
  • Racket
  • GNU Epsilon