| Members | Descriptions |
|---|---|
void init_chain(Chain * chain) |
Construct chain |
void clear_chain(Chain * chain) |
Clear chain |
void append_cstr_to_chain(Chain * chain,const char * text) |
Append a cstring to a chain |
void append_flink_to_chain(Chain * chain,Fraction fraction) |
Append fraction as single Link to chain |
void append_fraction_to_chain(Chain * chain,Fraction fraction) |
Append fraction as string to chain |
void append_chain_to_chain(Chain * chain1,Chain chain2) |
Append the contents in one chain to another |
void append_stream_to_chain(Chain * chain,FILE * stream) |
Append the contents of a stream to a chain |
void clear_stream(FILE * stream) |
Erase stream contents |
void append_chain_to_stream(Chain chain,FILE * stream) |
Append chain to stream |
void chain_to_stream(Chain chain,FILE * stream) |
Assign chain to stream |
int chain_to_cstr(Chain chain,char * buffer) |
Convert chain to cstring |
void write_chain_to_file(Chain chain,Chain filename) |
Set file contents to chain's contents |
void read_file_to_chain(Chain * chain,Chain filename) |
Set chain contents to file's contents |
int compare_chains(Chain a,Chain b) |
Compare chains |
``Fraction` ``chain_to_fraction``(``Chain`` chain)` |
Convert chain to fraction |
``Fraction` ``get_next_byte_of_stream``(FILE * file)` |
|
void runtime_error(const char * msg,...) |
Show error message and exit |
``Fraction` ``construct_fraction``(FractionInt num,FractionInt den)` |
Construct Fraction |
void reduce_fraction(Fraction * a) |
Reduce fraction to most basic form |
``Fraction` ``add_fractions``(``Fraction`` a,``Fraction`` b)` |
Add two fractions |
``Fraction` ``subtract_fractions``(``Fraction`` a,``Fraction`` b)` |
Subtract two fractions |
``Fraction` ``multiply_fractions``(``Fraction`` a,``Fraction`` b)` |
Multiply two fractions |
``Fraction` ``divide_fractions``(``Fraction`` a,``Fraction`` b)` |
Divide two fractions |
``Fraction` ``modulus_fractions``(``Fraction`` a,``Fraction`` b)` |
Modulus fractions |
``Fraction` ``factorial_fraction``(``Fraction`` a)` |
Get factorial of fraction |
int compare_fractions(Fraction a,Fraction b) |
Compare fractions |
``Fraction` ``pow_fractions``(``Fraction`` a,``Fraction`` b)` |
Exponentiate fractions |
struct Chain |
|
struct Fraction |
|
struct Link |
void init_chain(Chain * chain)
Construct chain
Set defaults for chain: length to 0 and start to NULL
chainThe chain being constructed
void clear_chain(Chain * chain)
Clear chain
Free all links in chain and set start to NULL
chainThe chain being cleared
void append_cstr_to_chain(Chain * chain,const char * text)
Append a cstring to a chain
Append each character of the cstring as a Link to the chain.
-
chainThe chain being modified -
textThe string being added to the chain
void append_flink_to_chain(Chain * chain,Fraction fraction)
Append fraction as single Link to chain
-
chainThe chain being modified -
fractionThe fraction being added to the chain
void append_fraction_to_chain(Chain * chain,Fraction fraction)
Append fraction as string to chain
Fraction is first converted into a string format. For example, 25/1 would be converted to "twenty five" and then appended to the chain
-
chainThe chain being modified -
fractionThe fraction being added to the chain
void append_chain_to_chain(Chain * chain1,Chain chain2)
Append the contents in one chain to another
-
chain1The chain being modified -
chain2The chain being appended to chain1
void append_stream_to_chain(Chain * chain,FILE * stream)
Append the contents of a stream to a chain
Each char is read from the stream and copied to the chain as a fraction/Link.
-
chainThe chain being modified -
streamThe stream whose contents are read
void clear_stream(FILE * stream)
Erase stream contents
streamThe stream being cleared
void append_chain_to_stream(Chain chain,FILE * stream)
Append chain to stream
Print each fraction of chain to the stream to be appended as a char
-
chainThe chain being read -
streamThe stream being appended to
void chain_to_stream(Chain chain,FILE * stream)
Assign chain to stream
Clear the stream, then call append_chain_to_stream
-
chainThe chain being read -
streamThe stream being copied to
int chain_to_cstr(Chain chain,char * buffer)
Convert chain to cstring
Print each fraction of chain to the cstring buffer to be appended as a char This function is not safe. If buffer is too small to hold the contents of chain, a segfault will occur
-
chainThe chain being read -
bufferThe cstring being appended to
The length of the buffer.
void write_chain_to_file(Chain chain,Chain filename)
Set file contents to chain's contents
Open a file and set its contents to that of the chain's. As with other functions, each fraction is converted to a char. An error will be thrown upon any problem opening the file
-
chainThe chain being read -
filenameA chain holding the filename of the file we're opening
void read_file_to_chain(Chain * chain,Chain filename)
Set chain contents to file's contents
Open a file and read its contents to the chain's, replacing any previous values(an assign, not append). As with other functions, each char is converted to a fraction. An error will be thrown upon any problem opening the file
-
chainThe chain being overwritten -
filenameA chain holding the filename of the file we're opening
int compare_chains(Chain a,Chain b)
Compare chains
Check if chains are equivalent. Will return 0 if they are, and another value if they are not.
-
aThe first chain -
bThe second chain
The comparison value
``Fraction` ``chain_to_fraction``(``Chain`` chain)`
Convert chain to fraction
Parse chain to convert to a fraction value. Return 0/1 if chain is invalid.
chainThe chain being parsed
The fraction value of the chain
``Fraction` ``get_next_byte_of_stream``(FILE * file)`
void runtime_error(const char * msg,...)
Show error message and exit
Shows an error in the style of fprintf in red text, then exit with EXIT_FAILURE
-
msgThe fprintf-style format string -
...Any values referenced by the format string
``Fraction` ``construct_fraction``(FractionInt num,FractionInt den)`
Construct Fraction
-
numThe numerator -
denThe denominator
The fraction constructed
void reduce_fraction(Fraction * a)
Reduce fraction to most basic form
aThe fraction to be reduced
``Fraction` ``add_fractions``(``Fraction`` a,``Fraction`` b)`
Add two fractions
-
aThe first fraction -
bThe second fraction
a+b
``Fraction` ``subtract_fractions``(``Fraction`` a,``Fraction`` b)`
Subtract two fractions
-
aThe first fraction -
bThe second fraction
a-b
``Fraction` ``multiply_fractions``(``Fraction`` a,``Fraction`` b)`
Multiply two fractions
-
aThe first fraction -
bThe second fraction
a*b
``Fraction` ``divide_fractions``(``Fraction`` a,``Fraction`` b)`
Divide two fractions
-
aThe first fraction -
bThe second fraction
a/b
``Fraction` ``modulus_fractions``(``Fraction`` a,``Fraction`` b)`
Modulus fractions
Get remainder after dividing two fractions. Throw an error if the fractions are non-integers
-
aThe first fraction -
bThe second fraction
ab
``Fraction` ``factorial_fraction``(``Fraction`` a)`
Get factorial of fraction
Return the factorial of a fraction. Throw an error if the fractions are non-integers
aThe fraction to be factorialized
a!
int compare_fractions(Fraction a,Fraction b)
Compare fractions
Return 0 if fractions are equal, -1 if a<b, and 1 if a>b
-
aThe first fraction -
bThe second fraction
The comparison result
``Fraction` ``pow_fractions``(``Fraction`` a,``Fraction`` b)`
Exponentiate fractions
Return a to the bth power. This uses floating point math, so the answer will not be exact. Invalid arguments will throw an error.
-
aThe first fraction -
bThe second fraction
a^b
| Members | Descriptions |
|---|---|
ChainLengthInt length |
|
``Link` * ``start` |
|
``Link` * ``end` |
ChainLengthInt length
| Members | Descriptions |
|---|---|
FractionInt num |
|
FractionInt den |
FractionInt num
FractionInt den
| Members | Descriptions |
|---|---|
``Fraction` ``value` |
|
struct Link*prev |
|
struct Link*next |
Generated by Moxygen