next up previous contents index
Next: 'insertion-sort' Up: Insertion Sort Previous: Insertion Sort   Contents   Index

sorted insertion into a list


\begin{lstlisting}[language=Scm]{}
(define insert (lambda(x l)
(if (nullp l)
(...
...x (car l))
(cons x l)
(cons (car l)
(insert x (cdr l)))))))
\end{lstlisting}


\begin{lstlisting}[language=Scm]{}
(define l1 (cons one (cons three (cons four nil))))
;
(ldisp! (insert two l1))
--> 1
2
3
4
\end{lstlisting}



Georg P. Loczewski 2004-03-05

Impressum und Datenschutz
access counter