Reputation: 23
I have a list of the form:
(or a b c (and d e) f g (and h i) (==> x y))
and I like to move the sublists beginning with and
after the or
like this:
(or (and d e) (and h i) a b c f g (==> x y))
How can I do this? I'm not sure what's the best way since it's a list and I can't just put an element whatever I want, like I can with other data structures.
Upvotes: 1
Views: 536
Reputation: 139251
? (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))
Upvotes: 1