Re: (apply #'and '(t t nil)) not work



fishmacs <wzhao1984@xxxxxxxxx> writes:

"Alex Mizrahi" <udodenko@xxxxxxxxxxxxxxxxxxxxx> writes:

of course you can define your own function -- to get rid of #'indetity
parameter, or allowing it to agruments directly. i.e.

(defun my-and (&rest args) (every #'identity args))

CL-USER> (my-and t t nil)
NIL
CL-USER> (apply #'my-and '(t t nil))
NIL

this looks just like AND, but it does not short-circuit evaluation.
Thanks all responses. But I do need short-circuit evalution.
I wrote a macro(very silly):
(defmacro andl (lst)
`(and ,@lst))
if type (andl '(1)) in the REPL, I get the error:
EVAL: variable QUOTE has no value

And who said EVERY and SOME don't do short circuit?


(every (function print) '(t t t nil 1 2 3 4))
prints:
T
T
T
NIL
returns:
NIL

(some (function print) '(nil nil nil t 1 2 3 4))
prints:
NIL
NIL
NIL
T
returns:
T


--
__Pascal Bourguignon__
.



Relevant Pages

  • Re: Noob question I think
    ... so I get and error that says nil is not of type NO. ... CL-USER> pai linha coluna id-nr) ... CL-USER> (defun insereMP (abertos no) ...
    (comp.lang.lisp)
  • Re: #0= ... #0#
    ... (do ((line (read-line stream nil nil) ... CL-USER> &body code) ... CL-USER> (write (macroexpand-1 form) ... The macro has built a confluent data structure. ...
    (comp.lang.lisp)
  • Re: How to eliminate eval?
    ... CL-USER> ) ... NIL)) ) ... CL-USER> (create-parameter 'a nil) ... (create-parameter (intern var) ...
    (comp.lang.lisp)
  • Re: (apply #and (t t nil)) not work
    ... CL-USER> (my-and t t nil) ... (defmacro andl (lst) ... variable QUOTE has no value ...
    (comp.lang.lisp)
  • Re: Macro woes
    ... CL-USER> (macroexpand '(test #'+)) ... CL-USER> `,(functionp x)) ... always expands into NIL. ...
    (comp.lang.lisp)