Filtering sublists

I have a question that should be quite simple, but I can’t figure out how to do it. I would like to filter a list in such a way that I only keep sublists of a certain length (say 1, or 2).

Say I have a list ((6000) (6000) (6400 6700) (6400 6700) (6000) (6000) (6400 6700) (6400 6700)), and I want to end up with ((6400 6700) (6400 6700) (6400 6700) (6400 6700)).

I suspect I’m going to have to dig into omif, or mapcar, but if there’s a simple way to do this, I would appreciate a pointer. (Better yet, if it could be done on the object level, I thought there was tool for that in OMTristan, but I was mistaken).

Thanks in advance!

One possibility is to use REMOVE-IF.
The first argument is a test (a function or OM patch in “lambda” mode) which can be someting like
(not (= (length X) 2))
The second argument is your list, and the test will be applied to each elements in it.

1 Like