ยทยทยท@zedat.fu-berlin.de (Stefan Ram) writes:
> ( defun noun-phrase-start()
> ( loop until( setq result( append-a-random-noun-to( a-random-determiner ))))
> result )
>
> The intention is to return the first result of
> "append-a-random-noun-to" that is not nil. Just for curiosity,
> is there a more idiomatic way to write this?
(defun noun-phrase-start ()
(loop for result = (append-a-random-noun-to (a-random-determiner))
when result return result))
Or using the loop anaphora reference:
(defun noun-phrase-start ()
(loop when (append-a-random-noun-to (a-random-determiner)) return it))
And yes, the parentheses placement matters.
--
Thomas A. Russ, USC/Information Sciences Institute