From ff3f8a2c3a9c011e94cd0ee47c9bcf0c4bef3766 Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Sun, 7 Jul 2024 18:12:07 -0500 Subject: [PATCH] Add digits, fibonacci --- docs/c.rst | 1 + docs/c/digits.rst | 39 +++++++++++++++++++++++++++++++++++++++ docs/c/fibonacci.rst | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 docs/c/digits.rst create mode 100644 docs/c/fibonacci.rst diff --git a/docs/c.rst b/docs/c.rst index 2d031a14..b8baa66a 100644 --- a/docs/c.rst +++ b/docs/c.rst @@ -16,6 +16,7 @@ Library Code c/bcd c/digits c/factors + c/fibonacci c/iterator c/macros c/math diff --git a/docs/c/digits.rst b/docs/c/digits.rst new file mode 100644 index 00000000..bb0693ef --- /dev/null +++ b/docs/c/digits.rst @@ -0,0 +1,39 @@ +digits.h +======== + +.. c:namespace-push:: digits + +.. c:type:: digit_counter + + Implements the :c:macro:`Iterator ` API + and yields successive decimal digits of a given number. + + .. c:member:: unsigned char (*iterator_function)(*digit_counter) + + The function to advance the iterator and return the next element. + + .. c:member:: bool exhausted : 1 + + An indicator that tells you if the iterator is exhausted. + + .. c:member:: bool started : 1 + + An indicator that tells you if the interator has moved at all. + + .. c:member:: bool phase : 1 + + An indicator that flips every time the iterator moves. + + .. c:member:: unsigned char *digits + + This array holds the individual digits of a parsed integer. + + .. c:member:: size_t idx + + This represents the current position in :c:member:`digits`. + + .. c:function:: digit_counter digits(uintmax_t n) + + .. c:function:: void free_digit_counter(digit_counter dc) + +.. c:namespace-pop:: diff --git a/docs/c/fibonacci.rst b/docs/c/fibonacci.rst new file mode 100644 index 00000000..18a2b190 --- /dev/null +++ b/docs/c/fibonacci.rst @@ -0,0 +1,38 @@ +fibonacci.h +======== + +.. c:namespace-push:: fibonacci + +.. c:type:: fibonacci + + Implements the :c:macro:`Iterator ` API + and yields successive Fibonacci numbers. + + .. c:member:: uintmax_t (*iterator_function)(*digit_counter) + + The function to advance the iterator and return the next element. + + .. c:member:: bool exhausted : 1 + + An indicator that tells you if the iterator is exhausted. + + .. c:member:: bool started : 1 + + An indicator that tells you if the interator has moved at all. + + .. c:member:: bool phase : 1 + + An indicator that flips every time the iterator moves. + + .. c:member:: uintmax_t a + .. c:member:: uintmax_t b + + .. c:member:: uintmax_t limit + + This represents the largest number the iterator is allowed to yield. + + .. c:function:: fibonacci fibonacci1(uintmax_t limit) + + .. c:function:: fibonacci fibonacci0() + +.. c:namespace-pop::