[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- Subject: None
- From: "Jeff Monroe" <firstname.lastname@example.org>
- Date: 26 May 1993 14:26:15 U
CC: "Info MCL" <email@example.com>
Subject: Time:2:28 PM
OFFICE MEMO None Date:5/26/93
> I am currently learning common lisp. It seems to me that lisp is pretty
> to handle more complex algorithm, although its syntax looks easier.
> I'd like to implement a sort(insertion and selection) function using
> simple functions like DEFUN, CAR, CDR, >, LAMBDA, ... etc. However, I never
> my sort function work. I know lisp has a sort function provided but i like to
> see the actual imlementation.
>If anyone has a sort function(any), can you send me a copy?
>OR if you know how to implement one easily, can you drop me a line?
>thanks for any help
The following ought to do a single insertion into a list of integers. A full
insertion sort using this should be easy enough.
(defun insert (item list)
(cond ((null list) (list item))
((< item (car list)) (cons item list))
(t (cons (car list) (insert item (cdr list))))
ie (insert 3 '(1 2 4 5)) -> '(1 2 3 4 5)