[Openmcl-devel] (null #())

Stas Boukarev stassats at gmail.com
Sun Oct 7 08:30:24 PDT 2012


Raymond Wiker <rwiker at gmail.com> writes:

> On Oct 7, 2012, at 16:59 , Stas Boukarev <stassats at gmail.com> wrote:
>> Taoufik Dachraoui <dachraoui.taoufik at gmail.com> writes:
>> 
>>> Hi
>>> 
>>> how to check that a sequence is null without using length?
>> (alexandria:sequence-of-length-p sequence 0)
>
>
> Or just
>
> (defun is-null-vector (v)
>               (and (vectorp v)
>                    (zerop (first (array-dimensions v)))))

(first (array-dimensions v)) is exactly (length v) on vectors.
But the question was about sequences, not just vectors. LENGTH on lists
is O(n), that's why it's undesirable. So, that leaves either
alexandria:sequence-of-length-p or (or (null x) (zerop (length x)))

-- 
With best regards, Stas.



More information about the Openmcl-devel mailing list