Fix examples based on older versions, add build examples script
This commit is contained in:
parent
f4d4a8ab00
commit
48218b0cdb
7 changed files with 38 additions and 16 deletions
|
|
@ -1,16 +1,17 @@
|
|||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#define LAZY_IMPL
|
||||
#include "lazy.h"
|
||||
#include "../lazy.h"
|
||||
|
||||
int main() {
|
||||
Lz_DA(float) nums = {0};
|
||||
lz_da_reserve(nums, 64);
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
for (size_t i = 0; i < 32; ++i) {
|
||||
lz_da_append(nums, 2.0*i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < nums.cnt; ++i) {
|
||||
printf("%f\n", nums.elts[i]);
|
||||
for (size_t i = 0; i < nums.cnt; ++i) {
|
||||
printf("%f\n", nums.data[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#define LAZY_IMPL
|
||||
#include "../lazy.h"
|
||||
|
||||
|
|
@ -9,14 +10,14 @@ int main() {
|
|||
lz_da_append(xs, 4);
|
||||
lz_da_shrink_to_fit(xs);
|
||||
|
||||
for (int i = 0; i < xs.cnt; ++i) {
|
||||
printf("%d: %d\n", i, xs.elts[i]);
|
||||
for (size_t i = 0; i < xs.cnt; ++i) {
|
||||
printf("%zu: %d\n", i, xs.data[i]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
lz_da_insert(xs,1,2);
|
||||
|
||||
for (int i = 0; i < xs.cnt; ++i) {
|
||||
printf("%d: %d\n", i, xs.elts[i]);
|
||||
for (size_t i = 0; i < xs.cnt; ++i) {
|
||||
printf("%zu: %d\n", i, xs.data[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#define LAZY_IMPL
|
||||
#include "lazy.h"
|
||||
#include "../lazy.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
|
@ -7,16 +7,16 @@
|
|||
int isnotalpha(int x) { return !isalpha(x); }
|
||||
|
||||
int main() {
|
||||
char *src = strdup("This is a list of words, which apparently has been referred to previously as a sentence")
|
||||
char *src = lz_cstr_dup("This is a list of words, which apparently has been referred to previously as a sentence");
|
||||
Lz_Slc s = lz_cstr_to_slc(src);
|
||||
|
||||
Lz_Slc word;
|
||||
int i = 0;
|
||||
do {
|
||||
lz_split_slc_typ(&s, isnotalpha, &word);
|
||||
printf("Word %d: "LZ_SLC_FMT"\n", i, LZ_SLC_PRINTF(word));
|
||||
printf("Word %d: "LZ_STR_FMT"\n", i, LZ_STR_PRINTF(word));
|
||||
++i;
|
||||
} while(s.len != 0);
|
||||
} while(s.cnt != 0);
|
||||
|
||||
free(src);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#define LAZY_IMPL
|
||||
#include "lazy.h"
|
||||
#include "../lazy.h"
|
||||
|
||||
int main() {
|
||||
char *src = strdup(" \t This text has some extra whitespace \t ");
|
||||
char *src = lz_cstr_dup(" \t This text has some extra whitespace \t ");
|
||||
Lz_Slc s = lz_cstr_to_slc(src);
|
||||
|
||||
printf("|"LZ_SLC_FMT"|\n", LZ_SLC_PRINTF(s));
|
||||
printf("|"LZ_STR_FMT"|\n", LZ_STR_PRINTF(s));
|
||||
lz_trim_typ(&s, isspace);
|
||||
printf("|"LZ_SLC_FMT"|\n", LZ_SLC_PRINTF(s));
|
||||
printf("|"LZ_STR_FMT"|\n", LZ_STR_PRINTF(s));
|
||||
|
||||
free(src); // excessive but this is how you should do it
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue