forked from mirrors/org-mode
54ab0e1c60
* ob-C.el: handling of non-homogeneous tables, support for table header, support for iterating over table cells. (org-babel-expand-body:C++): uncomment (org-babel-C-execute): cosmetic changes (org-babel-C-expand-C): add support for table columns names, add support for table dimensions, add standard includes (org-babel-C-val-to-C-type): rewrite to support non-homogeneous tables cells (org-babel-C-table-sizes-to-C): new function to gain access to the table dimensions (org-babel-C-utility-header-to-C): (org-babel-C-header-to-C): new functions to generate support for table header. * ob-C-test.org: added D sibling tests similar to C++, added non-homogeneous table example for C++ and D * test-ob-C.el: new tests for D and non-homogeneous tables (ob-C/simple-program): (ob-C/simple-program): (ob-D/simple-program): (ob-C/integer-var): (ob-D/integer-var): (ob-C/two-integer-var): (ob-D/two-integer-var): (ob-C/string-var): (ob-D/string-var): (ob-C/preprocessor): (ob-C/table): (ob-D/table): (ob-C/list-var): (ob-D/list-var): (ob-C/vector-var): (ob-D/vector-var): (ob-C/list-list-var): (ob-D/list-list-var): (ob-C/inhomogeneous_table): (ob-D/inhomogeneous_table): add compiler availability check (ob-D/simple-program): (ob-D/integer-var): (ob-D/two-integer-var): (ob-D/string-var): (ob-D/table): (ob-D/list-var): (ob-D/vector-var): (ob-D/list-list-var): (ob-D/inhomogeneous_table): add D unit tests (ob-C/inhomogeneous_table): (ob-D/inhomogeneous_table): add non-homogeneous table unit tests
3.6 KiB
3.6 KiB
a collection of examples for ob-C tests
Simple tests
std::cout << 42;
return 0;
writefln ("%s", 42);
std::cout << q;
return 0;
writefln ("%s", q);
std::cout << p+q;
return 0;
writefln ("%s", p+q);
std::cout << q << ' ' << std::strlen(q);
return 0;
writefln ("%s %s", q, q.length);
std::cout << N;
return 0;
Array
for (int i=1; i<3; i++) {
std::cout << i << '\n';
}
return 0;
foreach (i; 1..3)
writefln ("%s", i);
Matrix
1 | 2 |
3 | 4 |
std::cout << a[0] << a[1] << sizeof(a)/sizeof(*a) << '\n';
writefln ("%s%s%s", a[0], a[1], a.length);
std::cout << a[0] << a[1] << sizeof(a)/sizeof(*a) << '\n';
writefln ("%s%s%s", a[0], a[1], a.length);
std::cout << q[0][0] << ' ' << q[1][0] << '\n'
<< q[0][1] << ' ' << q[1][1] << '\n'; // transpose
writefln ("%s %s", q[0][0], q[1][0]);
writefln ("%s %s", q[0][1], q[1][1]); // transpose
Inhomogeneous table
day | quty |
---|---|
monday | 34 |
tuesday | 41 |
wednesday | 56 |
thursday | 17 |
friday | 12 |
saturday | 7 |
sunday | 4 |
int main()
{
int i, j;
for (i=0; i<tinomogen_rows; i++) {
for (j=0; j<tinomogen_cols; j++)
printf ("%s ", tinomogen[i][j]);
printf ("\n");
}
printf ("Friday %s\n", tinomogen_h(4,"day"));
return 0;
}
import std.stdio;
void main()
{
for (int i=0; i<tinomogen_rows; i++) {
for (int j=0; j<tinomogen_cols; j++)
writef ("%s ", tinomogen[i][j]);
writeln();
}
writefln ("Friday %s\n", tinomogen_h(4,"day"));
}