bool
Overview
Module with functions and types to work with bool values.
Types and Definitions
Functions
overall
bool_c_
#define bool_c_( Value )
Macro function that casts the Value as bool.
cmp_bool_c
int cmp_bool_c( bool a, bool b );
Compares two bool values and returns the three possible results:
- <0
-
means that a is less compared to b
- 0
-
means that a and b are equal
- >0
-
means that a is greater compared to b
Example
#include "clingo/lang/expect.h"
#include "clingo/type/bool.h"
int main( void )
{
init_tap_c_();
expect_lt_c_( cmp_bool_c( false, true ) );
expect_eq_c_( cmp_bool_c( false, false ) );
expect_eq_c_( cmp_bool_c( true, true ) );
expect_gt_c_( cmp_bool_c( true, false ) );
return finish_tap_c_();
}
algo
and_bool_slice_values_c
bool and_bool_slice_values_c( cBoolSlice slice );
Combines all values in the slice with a logical and operation.
Example
#include "clingo/lang/expect.h"
#include "clingo/type/bool.h"
int main( void )
{
init_tap_c_();
cBoolSlice s000 = slice_c_( bool, false, false, false );
cBoolSlice s001 = slice_c_( bool, false, false, true );
cBoolSlice s010 = slice_c_( bool, false, true, false );
cBoolSlice s011 = slice_c_( bool, false, true, true );
cBoolSlice s100 = slice_c_( bool, true, false, false );
cBoolSlice s101 = slice_c_( bool, true, false, true );
cBoolSlice s110 = slice_c_( bool, true, true, false );
cBoolSlice s111 = slice_c_( bool, true, true, true );
expect_c_( not and_bool_slice_values_c( s000 ) );
expect_c_( not and_bool_slice_values_c( s001 ) );
expect_c_( not and_bool_slice_values_c( s010 ) );
expect_c_( not and_bool_slice_values_c( s011 ) );
expect_c_( not and_bool_slice_values_c( s100 ) );
expect_c_( not and_bool_slice_values_c( s101 ) );
expect_c_( not and_bool_slice_values_c( s110 ) );
expect_c_( and_bool_slice_values_c( s111 ) );
return finish_tap_c_();
}
count_eq_bool_c
int64_t count_eq_bool_c( cBoolSlice slice, bool val );
Via the macro COUNT_EQ_C_ implemented function.
Example
#include "clingo/lang/expect.h"
#include "clingo/type/bool.h"
int main( void )
{
init_tap_c_();
cBoolSlice s01010 = slice_c_( bool, false, true, false, true, false );
expect_c_( count_eq_bool_c( s01010, true ) == 2 );
expect_c_( count_eq_bool_c( s01010, false ) == 3 );
return finish_tap_c_();
}
or_bool_slice_values_c
bool or_bool_slice_values_c( cBoolSlice slice );
Combines all values in the slice with a logical or operation.
Example
#include "clingo/lang/expect.h"
#include "clingo/type/bool.h"
int main( void )
{
init_tap_c_();
cBoolSlice s000 = slice_c_( bool, false, false, false );
cBoolSlice s001 = slice_c_( bool, false, false, true );
cBoolSlice s010 = slice_c_( bool, false, true, false );
cBoolSlice s011 = slice_c_( bool, false, true, true );
cBoolSlice s100 = slice_c_( bool, true, false, false );
cBoolSlice s101 = slice_c_( bool, true, false, true );
cBoolSlice s110 = slice_c_( bool, true, true, false );
cBoolSlice s111 = slice_c_( bool, true, true, true );
expect_c_( not or_bool_slice_values_c( s000 ) );
expect_c_( or_bool_slice_values_c( s001 ) );
expect_c_( or_bool_slice_values_c( s010 ) );
expect_c_( or_bool_slice_values_c( s011 ) );
expect_c_( or_bool_slice_values_c( s100 ) );
expect_c_( or_bool_slice_values_c( s101 ) );
expect_c_( or_bool_slice_values_c( s110 ) );
expect_c_( or_bool_slice_values_c( s111 ) );
return finish_tap_c_();
}