You are not logged in.
Pages: 1
Some time ago, I started (re)learning Lisp, and being used to work with vim (and not with emacs), I googled for "lisp vim" and of the first results was Limp (http://mikael.jansson.be/hacking/limp/docs/)). The problem is that when I indent code, it gets like this:
(defun combinations (elts)
(dolist (val elts) ; verify that only atoms are given
(if (or (not (atom val)) (null val))
(progn (format t "List must contain only atoms")
(abort))))
(format t "Number of diferent arrangement: ~D" (factorial (length elts)))
(do-combinations elts))
(defun do-combinations (elts)
(if (= (length elts) 2) ; base case
(list elts (reverse elts))
(let ((res ()) (aux ()))
(dolist (obj elts)
(setf aux (do-combinations (remove obj elts)))
(dolist (obj1 aux)
(setf res (append res (list (append (list obj) obj1))))))
res)))
;;; borrowed from wikipedia... http://en.wikipedia.org/wiki/Lisp_programming_language
(defun factorial (n &optional (acc 1))
(if (<= n 1)
acc
(factorial (- n 1) (* acc n))))
EDIT: while trying to fix the indentation in the post to show how vim really indents the code, I accidentally clicked the Submit button instead of Preview. I manually fixed only the first function (combinations) to show the problem: from what I've read about Lisp indenting, the first "if" should be indented with two spaces in relation to the previous "dolist", instead of aligned with "dolist" argument list. Right?
(the other two functions are not shown as vim indents them, because of copy/paste problems...)
Last edited by gauthma (2010-02-16 20:16:13)
Offline
:set lisp
is probably what you're looking for?
Offline
:set lisp
is probably what you're looking for?
That didn't work, but then I tried the same thing removing Limp, and yes it does the trick. Well now I know where lies the problem. Thanks for the idea!
Offline
Pages: 1