summaryrefslogtreecommitdiffhomepage
path: root/examples/list.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-11-26 15:08:07 +0100
committerTyge Løvset <[email protected]>2020-11-26 15:08:07 +0100
commitbdea38e432d109ba416d7f980f124da285d69a4f (patch)
treeeffeb89e993b01f374d5a44ce0b859f979ed7f27 /examples/list.c
parent65ad066312ed549472814e1576cec2f0dc0f51ea (diff)
downloadSTC-modified-bdea38e432d109ba416d7f980f124da285d69a4f.tar.gz
STC-modified-bdea38e432d109ba416d7f980f124da285d69a4f.zip
Removed stc/cfmt.h, as _Generic requires C11. I have made it a gist: https://gist.github.com/tylov/bcc956a4779f1d14204e66a14f17beb9
All examples are reverted to use printf() instead of c_print().
Diffstat (limited to 'examples/list.c')
-rw-r--r--examples/list.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/examples/list.c b/examples/list.c
index 81865020..4758b072 100644
--- a/examples/list.c
+++ b/examples/list.c
@@ -1,8 +1,7 @@
+#include <stdio.h>
#include <time.h>
#include <stc/clist.h>
#include <stc/crandom.h>
-#include <stc/cfmt.h>
-
using_clist(fx, double);
int main() {
@@ -16,26 +15,26 @@ int main() {
c_forrange (i, int, n)
clist_fx_push_back(&list, crand_uniform_f64(&eng, &dist)), ++m;
double sum = 0.0;
- c_print(1, "sumarize {}:\n", m);
+ printf("sumarize %d:\n", m);
c_foreach (i, clist_fx, list)
sum += *i.val;
- c_print(1, "sum {}\n\n", sum);
+ printf("sum %f\n\n", sum);
k = 0;
c_foreach (i, clist_fx, list)
- if (++k <= 10) c_print(1, "{:3}: {:16.6f}\n", k, *i.val); else break;
+ if (++k <= 10) printf("%8d: %10f\n", k, *i.val); else break;
puts("sort");
clist_fx_sort(&list); // mergesort O(n*log n)
puts("sorted");
k = 0;
c_foreach (i, clist_fx, list)
- if (++k <= 10) c_print(1, "{:3}: {:16.6f}\n", k, *i.val); else break;
+ if (++k <= 10) printf("%8d: %10f\n", k, *i.val); else break;
puts("");
clist_fx_clear(&list);
c_push_items(&list, clist_fx, {10, 20, 30, 40, 30, 50});
- c_foreach (i, clist_fx, list) c_print(1, " {}", *i.val);
+ c_foreach (i, clist_fx, list) printf(" %g", *i.val);
puts("");
int removed = clist_fx_remove(&list, 30);
@@ -43,13 +42,13 @@ int main() {
clist_fx_push_back(&list, 500);
clist_fx_push_front(&list, 1964);
clist_fx_iter_t it = clist_fx_before_begin(&list);
- c_print(1, "Full: ");
+ printf("Full: ");
c_foreach (i, clist_fx, list)
- c_print(1, " {}", *i.val);
+ printf(" %g", *i.val);
for (int i=0; i<4; ++i) clist_fx_next(&it);
- c_print(1, "\nSubs: ");
+ printf("\nSubs: ");
c_foreach (i, clist_fx, it, clist_fx_end(&list))
- c_print(1, " {}", *i.val);
+ printf(" %g", *i.val);
puts("");
clist_fx_del(&list);
} \ No newline at end of file