Post Scarcity
A prototype for a post scarcity programming environment
Loading...
Searching...
No Matches
equal.c File Reference
#include <math.h>
#include <stdbool.h>
#include "memory/conspage.h"
#include "memory/consspaceobject.h"
#include "arith/integer.h"
#include "arith/peano.h"
#include "arith/ratio.h"
#include "debug.h"
Include dependency graph for equal.c:

Go to the source code of this file.

Functions

bool end_of_string (struct cons_pointer string)
 Some strings will be null terminated and some will be NIL terminated... ooops!
 
bool eq (struct cons_pointer a, struct cons_pointer b)
 Shallow, and thus cheap, equality: true if these two objects are the same object, else false.
 
bool equal (struct cons_pointer a, struct cons_pointer b)
 Deep, and thus expensive, equality: true if these two objects have identical structure, else false.
 
bool equal_integer_number (struct cons_pointer a, struct cons_pointer b)
 Private function, don't use.
 
bool equal_integer_real (struct cons_pointer a, struct cons_pointer b)
 Private function, don't use.
 
bool equal_ld_ld (long double a, long double b)
 compare two long doubles and returns true if they are the same to within a tolerance of one part in a billion.
 
bool equal_number_number (struct cons_pointer a, struct cons_pointer b)
 Private function, don't use.
 
bool equal_real_number (struct cons_pointer a, struct cons_pointer b)
 Private function, don't use.
 
bool same_type (struct cons_pointer a, struct cons_pointer b)
 True if the objects at these two cons pointers have the same tag, else false.
 

Function Documentation

◆ end_of_string()

bool end_of_string ( struct cons_pointer  string)

Some strings will be null terminated and some will be NIL terminated... ooops!

Parameters
stringthe string to test
Returns
true if it's the end of a string.

Definition at line 47 of file equal.c.

References nilp, cons_space_object::payload, and pointer2cell.

Referenced by equal().

◆ eq()

bool eq ( struct cons_pointer  a,
struct cons_pointer  b 
)

Shallow, and thus cheap, equality: true if these two objects are the same object, else false.

equal.h

Definition at line 24 of file equal.c.

References cons_pointer::offset, and cons_pointer::page.

Referenced by equal(), equal_number_number(), lisp_add(), lisp_eq(), lisp_repl(), make_ratio(), and release_integer().

◆ equal()

bool equal ( struct cons_pointer  a,
struct cons_pointer  b 
)

◆ equal_integer_number()

bool equal_integer_number ( struct cons_pointer  a,
struct cons_pointer  b 
)

Private function, don't use.

It depends on its arguments being numbers and doesn't sanity check them.

Parameters
aa lisp integer – if it isn't an integer, things will break.
ba lisp number.
Returns
true if the two numbers have equal value.
false if they don't.

Definition at line 120 of file equal.c.

References DEBUG_ARITH, debug_print(), debug_print_object(), debug_printf(), equal_integer_integer(), equal_integer_real(), INTEGERTV, pointer2cell, RATIOTV, REALTV, and cons_space_object::tag.

Referenced by equal_number_number().

◆ equal_integer_real()

bool equal_integer_real ( struct cons_pointer  a,
struct cons_pointer  b 
)

Private function, don't use.

It depends on its arguments being numbers and doesn't sanity check them.

Parameters
aa lisp integer – if it isn't an integer, things will break.
ba lisp real – if it isn't a real, things will break.
Returns
true if the two numbers have equal value.
false if they don't.

Definition at line 87 of file equal.c.

References DEBUG_ARITH, debug_print(), debug_print_object(), debug_printf(), equal_ld_ld(), nilp, cons_space_object::payload, and pointer2cell.

Referenced by equal_integer_number(), and equal_real_number().

◆ equal_ld_ld()

bool equal_ld_ld ( long double  a,
long double  b 
)

compare two long doubles and returns true if they are the same to within a tolerance of one part in a billion.

Parameters
a
b
Returns
true if a and b are equal to within one part in a billion.
false otherwise.

Definition at line 61 of file equal.c.

References DEBUG_ARITH, and debug_printf().

Referenced by equal_integer_real(), and equal_real_number().

◆ equal_number_number()

bool equal_number_number ( struct cons_pointer  a,
struct cons_pointer  b 
)

Private function, don't use.

It depends on its arguments being numbers and doesn't sanity check them.

Parameters
aa number
ba number
Returns
true if the two numbers have equal value.
false if they don't.

Definition at line 195 of file equal.c.

References DEBUG_ARITH, debug_print(), debug_print_object(), debug_printf(), eq(), equal_integer_number(), equal_ratio_ratio(), equal_real_number(), INTEGERTV, pointer2cell, RATIOTV, REALTV, and cons_space_object::tag.

Referenced by equal().

◆ equal_real_number()

bool equal_real_number ( struct cons_pointer  a,
struct cons_pointer  b 
)

Private function, don't use.

It depends on its arguments being numbers and doesn't sanity check them.

Parameters
aa lisp real – if it isn't an real, things will break.
ba lisp number.
Returns
true if the two numbers have equal value.
false if they don't.

Definition at line 155 of file equal.c.

References c_ratio_to_ld(), DEBUG_ARITH, debug_print(), debug_print_object(), debug_printf(), equal_integer_real(), equal_ld_ld(), INTEGERTV, cons_space_object::payload, pointer2cell, RATIOTV, REALTV, and cons_space_object::tag.

Referenced by equal_number_number().

◆ same_type()

bool same_type ( struct cons_pointer  a,
struct cons_pointer  b 
)

True if the objects at these two cons pointers have the same tag, else false.

Parameters
aa pointer to a cons-space object;
banother pointer to a cons-space object.
Returns
true if the objects at these two cons pointers have the same tag, else false.

Definition at line 35 of file equal.c.

References pointer2cell, and cons_space_object::tag.

Referenced by equal().