Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't there a BOOLEANP predicate?

To check for a symbol, one might use symbolp. To check for a number, one might use numberp. And so on…

Why is there no booleanp to check for a boolean value? Of course I can use

(defun booleanp (x)
  (or (null x)
      (equal x t)))

but is there an easier (built-in) way of doing this? If not, is there a special reason, why just this predicate is missing?

like image 746
Golo Roden Avatar asked Apr 08 '15 16:04

Golo Roden


People also ask

Is predicate Boolean?

A predicate is a boolean function whose value may be true or false, depending on the arguments to the predicate. Predicates are a generalization of propositional variables. A propositional variable is a predicate with no arguments.

What is a Boolean expression predicate?

A Boolean predicate returns the truth value of a Boolean expression. boolean-expression IS NOT TRUE FALSE. boolean-expression. An expression that returns the Boolean value (or representation of a Boolean value) that is to be evaluated by the function.

How does predicate work in Java?

The predicate is a predefined functional interface in Java defined in the java. util. Function package. It helps with manageability of code, aids in unit-testing, and provides various handy functions.

Can I use nested terms in a boolean predicate?

Namely, the SP has to be able to parse and evaluate a Boolean predicate. Therefore, we advise against using nested terms, and utilizing only simple predicates. An additional problem is posed by lengthy predicates. The DNS-SD specification limits domain names to 253 characters.

What are valued predicates in SQL?

Valued predicates refer to a set of related unary Boolean predicates that return TRUE or FALSE based on a property of their argument. IS NULL is the only way to test to see if an expression is NULL or not, and it has been present in SQL-86 and all later versions of the standard.

How do you know if a transition is a valued predicate?

Given that an assertion a labels a transition t = ( u, v), with t ∈ T i, then we say a is violated if the formula f = u i ∧ ¬ a is satisfied. Valued predicates refer to a set of related unary Boolean predicates that return TRUE or FALSE based on a property of their argument.

What is predicate logic?

Predicate logic is the formal logician’s bread and butter (or Sriracha and literally any other food, if that’s more your thing). Predication identifies a property and tries to connect that property to all, some, or none of a group of things.


2 Answers

I don't know the exact history of numberp, symbolp, the boolean type, and other type predicates, but with the availability of the generic type predicate typep it is not necessary to have a separate predicate for every type. A short way to see if something is of type boolean is (typep object 'boolean).

like image 99
Xach Avatar answered Oct 23 '22 13:10

Xach


I'd dare to guess that the real reason for this is that even though only NIL and T are (TYPEP 'BOOLEAN), any value is a valid boolean expression. I.e. any value except for NIL is considered true in an IF form. Thus, the usefulness of a BOOLEANP would be limited, if not harmful as it would return false for things that are perfectly valid input to the conditional forms.

like image 27
Elias Mårtenson Avatar answered Oct 23 '22 14:10

Elias Mårtenson