From: Pedro Kröger
Subject: is there a function to convert a value to a boolean?
Date: 
Message-ID: <1164049647.563182.211400@k70g2000cwa.googlegroups.com>
Hi,

Is there a function in the specification to convert a value to a
boolean? It could be implemented like:

(defun bool (&optional (x nil))
  (if x t nil))

or

(defun bool (&optional (x nil))
  (not (not x)))

But I want to know if the specification already have something like it.
I looked and only found the 'boole' function.

It's useful to do things like:

;; returns true if all elements in sequence are true
(every #'bool sequence)

Pedro Kroger

From: Pascal Costanza
Subject: Re: is there a function to convert a value to a boolean?
Date: 
Message-ID: <4sed2lFvak1nU1@mid.individual.net>
Pedro Kr�ger wrote:
> Hi,
> 
> Is there a function in the specification to convert a value to a
> boolean? It could be implemented like:
> 
> (defun bool (&optional (x nil))
>   (if x t nil))
> 
> or
> 
> (defun bool (&optional (x nil))
>   (not (not x)))
> 
> But I want to know if the specification already have something like it.
> I looked and only found the 'boole' function.
> 
> It's useful to do things like:
> 
> ;; returns true if all elements in sequence are true
> (every #'bool sequence)

What's wrong with (every #'identity sequence)?


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Pedro Kröger
Subject: Re: is there a function to convert a value to a boolean?
Date: 
Message-ID: <1164050984.471682.269040@f16g2000cwb.googlegroups.com>
Pascal Costanza wrote:
> What's wrong with (every #'identity sequence)?

nothing, I forgot about identity. Thanks a lot.

Pedro
From: Tin Gherdanarra
Subject: Re: is there a function to convert a value to a boolean?
Date: 
Message-ID: <4sf2gsFvlu2mU1@mid.individual.net>
Pedro Kr�ger wrote:
> Hi,
> 
> Is there a function in the specification to convert a value to a
> boolean? It could be implemented like:
> 
> (defun bool (&optional (x nil))
>   (if x t nil))
> 
> or
> 
> (defun bool (&optional (x nil))
>   (not (not x)))
> 
> But I want to know if the specification already have something like it.
> I looked and only found the 'boole' function.
> 
> It's useful to do things like:
> 
> ;; returns true if all elements in sequence are true
> (every #'bool sequence)
> 
> Pedro Kroger
> 
This is more about the names. We can have a
two-people-standard on this:

(defun truth (x)
   (if (null x) nil t))

(defun truthp (x)
   (or (eq t x) (eq nil x)))

(defun truth-from-int (i)
   (not (zerop i)))

(defun int-from-truth (b)
   (if b 1 0))

I use these quite frequently for my chip-simulations.
I could not find other uses. What are you building at
home?

-- 
Lisp kann nicht kratzen, denn Lisp ist fluessig
From: Pedro Kröger
Subject: Re: is there a function to convert a value to a boolean?
Date: 
Message-ID: <1164107913.624782.169180@e3g2000cwe.googlegroups.com>
Tin Gherdanarra wrote:
> This is more about the names. We can have a
> two-people-standard on this:

thanks for the code.

> I use these quite frequently for my chip-simulations.
> I could not find other uses. What are you building at
> home?

nothing special, just studying lisp.

pedro