2013-02-01 45 views
0

我有以下形式的列表:Lisp的移动元素

(or a b c (and d e) f g (and h i) (==> x y)) 

和我一样的or这样后and移动子列表开始:

(or (and d e) (and h i) a b c f g (==> x y)) 

我怎样才能做这个?我不知道什么是最好的方式,因为它是一个列表,我不能只是把我想要的任何元素,就像我可以与其他数据结构一样。

回答

1
? (stable-sort (rest '(or a b c (and d e) f g (and h i) (==> x y))) 
       (lambda (x y) 
       (and (consp x) (eq (first x) 'and)))) 
((AND H I) (AND D E) A B C F G (==> X Y)) 
+0

谢谢,但初始或究竟在哪里? – user2033237

+0

好吧,我明白了 – user2033237