Re: [Scilab-users] Booeleans : irrelevant results ?

2015-08-27 Thread Pierre Vuillemin
 

Dear Paul, 

The behaviour of test 2 may come from the order in which the operations
are performed : 

Note that (a  c  b) ~= (b  c  a), indeed : 

- a  c  b performs a  c which returns [] and then []  b which
returns [], 

- b  c  a performs b  c which returns %t and then %t  [] which
returns %t. 

You can obtain the desired behaviour by adding parenthesis 

b  (c  a) returns [] 

but it may be safer to use isempty() to check whether a variable is
empty or not. 

Best regards, 

Pierre 

Le 27.08.2015 12:29, Carrico, Paul a écrit : 

 Dear All, 
 
 I wondering what I'm doing wrong in the examples here bellow: 
 
 - Test 1 à M returns False that's ok for me 
 
 - Test 2 à should return False as well, shouldn't be ? 
 
 - Test 3 à another test using directly a Boolean instead of an empty form [] 
 
 - Test 4 à as expected, it returns F 
 
 Thanks for any highlight 
 
 Paul 
 
 ##
  
 
 mode(0) 
 
 _// test 1_ 
 
 M = []; 
 
 if M then 
 
 printf(M returns T\n); 
 
 else 
 
 printf(M returns F\n); 
 
 end 
 
 _// test 2_ 
 
 a=[]; 
 
 b=30; 
 
 c=200; 
 
 if (b  c  a) then 
 
 printf(val = 6\n); 
 
 else printf(val = []\n); _// should return [] ??_ 
 
 end 
 
 _// test 3_ 
 
 tmp = %f; 
 
 _//tmp = %t;_ 
 
 if (tmp) then 
 
 printf(tmp returns T\n); 
 
 else 
 
 printf(tmp returns F\n); 
 
 end 
 
 _// test 4_ 
 
 t1 = %t; 
 
 t2 = %t; 
 
 _//t3 = %t;_ 
 
 t3 = %f; 
 
 if (t1  t2  t3) then 
 
 printf((t1,t2,t3) returns T\n); 
 
 else 
 
 printf((t1,t2,t3) returns F\n); 
 
 end 
 
 EXPORT CONTROL : 
 Cet email ne contient pas de données techniques
 This email does not contain technical data 
 
 ___
 users mailing list
 users@lists.scilab.org
 http://lists.scilab.org/mailman/listinfo/users [1]

 

Links:
--
[1] http://lists.scilab.org/mailman/listinfo/users
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Booeleans : irrelevant results ?

2015-08-27 Thread Carrico, Paul
Dear All,

I wondering what I'm doing wrong in the examples here bellow:

-  Test 1 -- M returns False that's ok for me

-  Test 2 -- should return False as well, shouldn't be ?

-  Test 3 -- another test using directly a Boolean instead of an empty 
form []

-  Test 4 -- as expected, it returns F

Thanks for any highlight

Paul

##
mode(0)

// test 1
M = [];
if M then
printf(M returns T\n);
else
printf(M returns F\n);
end

// test 2
a=[];
b=30;
c=200;

if (b  c  a) then
printf(val = 6\n);
else printf(val = []\n); // should return [] ??
end

// test 3
tmp = %f;
//tmp = %t;

if (tmp) then
printf(tmp returns T\n);
else
printf(tmp returns F\n);
end

// test 4
t1 = %t;
t2 = %t;
//t3 = %t;
t3 = %f;

if (t1  t2  t3) then
printf((t1,t2,t3) returns T\n);
else
printf((t1,t2,t3) returns F\n);
end

EXPORT CONTROL :
Cet email ne contient pas de données techniques
This email does not contain technical data

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Booeleans : irrelevant results ?

2015-08-27 Thread Carrico, Paul
Effectively it is much better to use isempty() function (or ~isempty() in the 
current case) … I didn’t know it so far

Many thanks for your help

Paul

EXPORT CONTROL :
Cet email ne contient pas de données techniques
This email does not contain technical data

De : Pierre Vuillemin [mailto:cont...@pierre-vuillemin.fr]
Envoyé : jeudi 27 août 2015 13:08
À : Users mailing list for Scilab
Cc : Carrico, Paul
Objet : Re: [Scilab-users] Booeleans : irrelevant results ?


Dear Paul,

The behaviour of test 2 may come from the order in which the operations are 
performed :



Note that (a  c  b) ~= (b  c  a), indeed :

- a  c  b performs a  c which returns [] and then []  b which returns [],

- b  c  a performs b  c which returns %t and then %t  [] which returns %t.

You can obtain the desired behaviour by adding parenthesis

b  (c  a) returns []

but it may be safer to use isempty() to check whether a variable is empty or 
not.



Best regards,



Pierre



Le 27.08.2015 12:29, Carrico, Paul a écrit :
Dear All,

I wondering what I’m doing wrong in the examples here bellow:

-  Test 1 -- M returns False that’s ok for me

-  Test 2 -- should return False as well, shouldn’t be ?

-  Test 3 -- another test using directly a Boolean instead of an empty 
form []

-  Test 4 -- as expected, it returns F

Thanks for any highlight

Paul

##”
mode(0)

// test 1
M = [];
if M then
printf(M returns T\n);
else
printf(M returns F\n);
end

// test 2
a=[];
b=30;
c=200;

if (b  c  a) then
printf(val = 6\n);
else printf(val = []\n); // should return [] ??
end

// test 3
tmp = %f;
//tmp = %t;

if (tmp) then
printf(tmp returns T\n);
else
printf(tmp returns F\n);
end

// test 4
t1 = %t;
t2 = %t;
//t3 = %t;
t3 = %f;

if (t1  t2  t3) then
printf((t1,t2,t3) returns T\n);
else
printf((t1,t2,t3) returns F\n);
end

EXPORT CONTROL :
Cet email ne contient pas de données techniques
This email does not contain technical data


___
users mailing list
users@lists.scilab.orgmailto:users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/usershttps://urldefense.proofpoint.com/v2/url?u=http-3A__lists.scilab.org_mailman_listinfo_usersd=AwMFaQc=0hKVUfnuoBozYN8UvxPA-wr=4TCz--8bXfJhZZvIxJAemAJyz7Vfx78XvgYu3LN7eLom=CsJzSea7OehSm_fgX8J6czbmq4kUd-ws1o3meFqpHeks=EFhyGA5WXCbkAbKVE545SI6VDStjViqsaNYDJ3bW3uwe=



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users