owhite@nmsu.edu (smouldering dog) (02/20/91)
hi I am new to lisp and I think it is incredibly useful for the work I
have been doing in DNA analysis.  I can't get this little hack to
work.  I sincerely would like to understand what is goin wrong and I
sincerely need someone's help:
make-length-list gets a cons-list like ((100 200) (300 400) (455 526))
and I just want it to return a cons-list (100 100 71).
(defun make-length-list(coord)
  (let ((first (car coord))
	(this ())
	(n1 0)
	(n2 0))
    (if coord
	(progn
	  (while coord
	  (let ((first (car coord))
	    (setq n1 (car coord))
	    (setq n2 (car (cdr coord))))
	    (cons (- n2 n1) this))
	  (setq coord (cdr coord)))))))
--
	owen white		(owhite@nmsu.edu)
-=-*-=-=-*-=-=-*-=-=-*-=-=-*-=-=-*-=-=-*-=-=-*-=-=-*-=-=-*-=-=-*-=-*-=-=-*-=-
               got my head on a pole (for better reception)
-=-*-=-=-*-=-=-*-=-=-*-=-=-*-=-=-*-=-=-*-=-=-*-=-=-*-=-=-*-=-=-*-=-*-=-=-*-=-iam@Gang-of-Four.Stanford.EDU (Ian Mason) (02/20/91)
try the following, somewhat more in the spirit of lisp (define f (list) (mapcar (function (lambda (x) (- (cadr x) (car x))) list))) -iam-
duthen@ircam.fr (Jacques Duthen) (02/21/91)
In article <OWHITE.91Feb19091907@haywire.nmsu.edu> owhite@nmsu.edu (smouldering dog) writes: >make-length-list gets a cons-list like ((100 200) (300 400) (455 526)) >and I just want it to return a cons-list (100 100 71). (defun make-length-list (coord) (mapcar #'(lambda (elt) (abs (- (second elt) (first elt)))) coord)) (make-length-list '((100 200) (300 400) (455 526))) ;= (100 100 71) ; Welcome to Lisp world ! [jack]