Go to the source code of this file.
◆ DefList
Value:struct Node##type { \
type head; \
struct Node##type* rest; \
}; \
typedef struct Node##type* List##type; \
void List##type##_deinit(List##type
list); \
type List##type##_car(struct Node##type node); \
struct Node##type* List##type##_cdr(struct Node##type node); \
List##type List##type##_cons(type a, List##type
list); \
List##type List##type##_rev(List##type
list, List##type a); \
List##type List##type##_reverse(List##type
list); \
size_t List##type##_length(List##type
list); \
type List##type##_at(List##type
list,
size_t index); \
List##type List##type##_drop(List##type
list,
size_t n); \
List##type List##type##_drop(List##type
list,
size_t n);
◆ ImplList
◆ ListOpaque
This is the actual type of the List.
◆ Opaque
◆ ListOpaque_at()
The indexing function for a List.
This will crash your program if you index outside of the List. INFO: the first index is 1. Similar: to https://cppreference.com/w/cpp/container/vector/at.html.
- Parameters
-
| list | the List to get the element from |
| index | the index of the element in the List |
- Returns
- the element at that index
◆ ListOpaque_car()
Returns the element at the head of the List.
This exists in case you want a functional style.
- Parameters
-
| node | the node to get the head from |
- Returns
- the element at the head of the List
◆ ListOpaque_cdr()
Returns the rest of the List, ignoring the first element.
This exists in case you want a functional style.
- Parameters
-
| node | the node to get the list from |
- Returns
- the rest of the List
◆ ListOpaque_cons()
Prepend an element to the List.
This is the main way of actually creating lists. For more information you can visit: https://hackage.haskell.org/package/base-4.21.0.0/docs/Data-List.html#t:List INFO: Caller must free memory
- Parameters
-
| fst | the element you want to prepend |
| list | the list you want to prepend to |
- Returns
- a List where the first element is fst and the rest of the List is list
◆ ListOpaque_deinit()
Deinitialize the List.
- Parameters
-
| list | the List to deinitialize |
◆ ListOpaque_length()
Returns the length of the List.
- Parameters
-
| list | the List that you want the length for |
- Returns
- the length of that List
◆ ListOpaque_rev()
Helper function for ListOpaque_reverse.
- Parameters
-
| list | the List that is being reversed |
| acc | the accumulator |
- Returns
- a reversed List
◆ ListOpaque_reverse()