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 */
|
||||
|
||||
typedef enum { RED, BLUE, GREEN } color;
|
||||
enum color { RED, BLUE, GREEN };
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ double average(std::vector<int> v) {
|
|||
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);
|
||||
for (unsigned int i=0; i<w.size(); i++)
|
||||
w[i] /= 2.0;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
%}
|
||||
|
||||
%include stl.i
|
||||
|
||||
/* instantiate the required template specializations */
|
||||
namespace std {
|
||||
%template(IntVector) vector<int>;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ double dvar = 0;
|
|||
char *strvar = 0;
|
||||
const char cstrvar[] = "Goodbye";
|
||||
int *iptrvar = 0;
|
||||
char name[5] = "Dave";
|
||||
char name[256] = "Dave";
|
||||
char path[256] = "/home/beazley";
|
||||
|
||||
|
||||
|
|
@ -51,10 +51,10 @@ void print_vars() {
|
|||
printf("dvar = %g\n", dvar);
|
||||
printf("cvar = %c\n", cvar);
|
||||
printf("strvar = %s\n", strvar ? strvar : "(null)");
|
||||
printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)");
|
||||
printf("iptrvar = %i\n", value_int(iptrvar));
|
||||
printf("name = %c%c%c%c%c\n", name[0],name[1],name[2],name[3],name[4]);
|
||||
printf("ptptr = %p (%d, %d)\n", ptptr, ptptr->x, ptptr->y);
|
||||
printf("cstrvar = %s\n", cstrvar);
|
||||
printf("iptrvar = %p\n", (void *)iptrvar);
|
||||
printf("name = %s\n", name);
|
||||
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("status = %d\n", status);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue