Synchronize common scilab examples with other languages
This commit is contained in:
parent
a41efbd0f7
commit
ea634d54a5
4 changed files with 7 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
/* File : example.h */
|
/* File : example.h */
|
||||||
|
|
||||||
typedef enum { RED, BLUE, GREEN } color;
|
enum color { RED, BLUE, GREEN };
|
||||||
|
|
||||||
class Foo {
|
class Foo {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ double average(std::vector<int> v) {
|
||||||
return std::accumulate(v.begin(),v.end(),0.0)/v.size();
|
return std::accumulate(v.begin(),v.end(),0.0)/v.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<double> half(const std::vector<double> v) {
|
std::vector<double> half(const std::vector<double>& v) {
|
||||||
std::vector<double> w(v);
|
std::vector<double> w(v);
|
||||||
for (unsigned int i=0; i<w.size(); i++)
|
for (unsigned int i=0; i<w.size(); i++)
|
||||||
w[i] /= 2.0;
|
w[i] /= 2.0;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include stl.i
|
%include stl.i
|
||||||
|
|
||||||
/* instantiate the required template specializations */
|
/* instantiate the required template specializations */
|
||||||
namespace std {
|
namespace std {
|
||||||
%template(IntVector) vector<int>;
|
%template(IntVector) vector<int>;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ double dvar = 0;
|
||||||
char *strvar = 0;
|
char *strvar = 0;
|
||||||
const char cstrvar[] = "Goodbye";
|
const char cstrvar[] = "Goodbye";
|
||||||
int *iptrvar = 0;
|
int *iptrvar = 0;
|
||||||
char name[5] = "Dave";
|
char name[256] = "Dave";
|
||||||
char path[256] = "/home/beazley";
|
char path[256] = "/home/beazley";
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -51,10 +51,10 @@ void print_vars() {
|
||||||
printf("dvar = %g\n", dvar);
|
printf("dvar = %g\n", dvar);
|
||||||
printf("cvar = %c\n", cvar);
|
printf("cvar = %c\n", cvar);
|
||||||
printf("strvar = %s\n", strvar ? strvar : "(null)");
|
printf("strvar = %s\n", strvar ? strvar : "(null)");
|
||||||
printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)");
|
printf("cstrvar = %s\n", cstrvar);
|
||||||
printf("iptrvar = %i\n", value_int(iptrvar));
|
printf("iptrvar = %p\n", (void *)iptrvar);
|
||||||
printf("name = %c%c%c%c%c\n", name[0],name[1],name[2],name[3],name[4]);
|
printf("name = %s\n", name);
|
||||||
printf("ptptr = %p (%d, %d)\n", ptptr, ptptr->x, ptptr->y);
|
printf("ptptr = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
|
||||||
printf("pt = (%d, %d)\n", pt.x, pt.y);
|
printf("pt = (%d, %d)\n", pt.x, pt.y);
|
||||||
printf("status = %d\n", status);
|
printf("status = %d\n", status);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue