1 #+Title: a collection of examples for ob-C tests
5 :ID: fa6db330-e960-4ea2-ac67-94bb845b8577
8 #+begin_src cpp :includes "<iostream>" :results silent
14 #+begin_src D :results silent
19 #+begin_src cpp :var q=12 :includes "<iostream>" :results silent
25 #+begin_src D :var q=12 :results silent
30 #+begin_src cpp :var q=12 :var p=10 :includes "<iostream>" :results silent
36 #+begin_src D :var q=12 :var p=10 :results silent
41 #+begin_src cpp :var q="word" :includes '(<iostream> <cstring>) :results silent
42 std::cout << q << ' ' << std::strlen(q);
47 #+begin_src D :var q="word" :results silent
48 writefln ("%s %s", q, q.length);
52 #+begin_src cpp :defines N 42 :includes "<iostream>" :results silent
59 :ID: 2df1ab83-3fa3-462a-a1f3-3aef6044a874
62 #+begin_src cpp :includes "<iostream>" :results vector :results silent
63 for (int i=1; i<3; i++) {
64 std::cout << i << '\n';
70 #+begin_src D :results vector :results silent
77 :ID: cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5
84 #+begin_src cpp :var a='("abc" "def") :includes "<iostream>" :results silent
85 std::cout << a[0] << a[1] << sizeof(a)/sizeof(*a) << '\n';
89 #+begin_src D :var a='("abc" "def") :results silent
90 writefln ("%s%s%s", a[0], a[1], a.length);
94 #+begin_src cpp :var a='[1 2] :includes "<iostream>" :results silent
95 std::cout << a[0] << a[1] << sizeof(a)/sizeof(*a) << '\n';
99 #+begin_src D :var a='[1 2] :results silent
100 writefln ("%s%s%s", a[0], a[1], a.length);
103 #+source: list_list_var
104 #+begin_src cpp :var q=C-matrix :includes "<iostream>" :results silent
105 std::cout << q[0][0] << ' ' << q[1][0] << '\n'
106 << q[0][1] << ' ' << q[1][1] << '\n'; // transpose
109 #+source: list_list_var
110 #+begin_src D :var q=C-matrix :results silent
111 writefln ("%s %s", q[0][0], q[1][0]);
112 writefln ("%s %s", q[0][1], q[1][1]); // transpose
115 * Inhomogeneous table
117 :ID: e112bc2e-419a-4890-99c2-7ac4779531cc
131 #+source: inhomogeneous_table
132 #+begin_src cpp :var tinomogen=tinomogen :results silent :includes <string.h> <stdio.h>
136 for (i=0; i<tinomogen_rows; i++) {
137 for (j=0; j<tinomogen_cols; j++)
138 printf ("%s ", tinomogen[i][j]);
141 printf ("Friday %s\n", tinomogen_h(4,"day"));
146 #+source: inhomogeneous_table
147 #+begin_src D :var tinomogen=tinomogen :results silent
151 for (int i=0; i<tinomogen_rows; i++) {
152 for (int j=0; j<tinomogen_cols; j++)
153 writef ("%s ", tinomogen[i][j]);
156 writefln ("Friday %s\n", tinomogen_h(4,"day"));