Professional Documents
Culture Documents
Submit by
Haider Ali
(17708)
Submitted To
Aisha Naseem
BACHELOR OF
SCIENCE
In computer science
6th Semester B
Introduction:
Lisp, which stands for list processing, is a functional programming
language that was created to facilitate the manipulation of data strings.
Lisp is one of the oldest programming languages still in use, with several
dialects that have influenced the development of other languages.
History:
Advantage:
(g ( e e a) 12 34 5)
(sun mon tue wed thur fri sat)
()
( People call me list)
(haider ( Love programming))
String
A string is a group of characters enclosed in double quotation marks.
" People call me string"
"Steps require to solve this is:"
"Hello 'How are you haider'! "
"a ba c d efg #$%^&!"
Example
Example 1:
Block code
#! /usr/bin/gcl -f
(block
myBlockName
(format t "this is my block~%")
(format t "return the list 1 2 3~%")
'(1 2 3)
)
; note that many of the different block forms (let, prog, etc)
; either use an implicit block name of nil
; or allow the programmer to assigne a name to the block
Example 2:
Local function
; sample global function, f1, with local functions f2 and f3
(defun f1 (p1)
; local function f2
(labels ; the first part of labels is a block of local function definitions
( ; create a local function f2, that takes parameters p2 and x
(f2 (p2 x)
; the body of the function prints p2 and x and returns their sum
(format t "in f2, p2 is ~A~%" p2)
(format t "in f2, x is ~A~%" x)
(+ p2 x)
)
; create a local function f3 that just squares p1
(f3 () (* p1 p1))
) ; end of local function definitions
(format t "the internal system run time for this process is ~A~%" (get-internal-
run-time))
(format t "...and now the time is ~A~%" (get-internal-run-time))
(format t "display the time to compute (* 3.5 3.5):~%")
(time (* 3.5 3.5))