# Functional programming -- 2008-2009 -- info.uvt.ro/Laboratory 7

 Functional programming (Spring 2010): front; laboratory: agenda, references, projects, tools; notes (normal paced): 1, 2, 3, 4, 5, 6, 7, 8 (Spring 2009); notes (fast paced): 1, 2, 3, 4 (Spring 2010) (discontinued); applications: robots; mailing list: send mail, view archive, subscribe; author: Ciprian Dorin Craciun, ccraciun@info.uvt.ro;

## Iterative forms

### References

• previous year laboratory:
• the Common Lisp Hyperspec reference:
• or:
• Cornel Izbasa's laboratory: [1];
• the Macros: Standard Control Constructs chapter from Practical Common Lisp: [2];
• the tutorial: [3], with the Control Structures and Variables section;

### Examples

• the examples were provided by:
• Dan Claudiu Codrean;
```> (defun sum (l)
(let ((s 0))
(dolist (i l s)
(if (numberp i)
(setq s (+ s i))))))
SUM
```
```> (defun map (l f)
(let ((r nil))
(dolist (i l (reverse r))
(setq r (cons (funcall f i) r)))))
MAP
```
```> (defun factorial-n (n)
(let ((r 1))
(dotimes (i n r)
(setq r (* r (1+ i))))))
FACTORIAL-N
```
```> (defun factorial-n (n)
(do
(
(i n (1- i))
((p 1 (* p i)))
(
(zerop i)
p)
))
FACTORIAL-N
```

## Associative lists

### References

• the Common Lisp Hyperspec reference:
• or:
• Cornel Izbasa's laboratory: [4];