[Scilab-users] Booeleans : irrelevant results ?
Pierre Vuillemin
contact at pierre-vuillemin.fr
Thu Aug 27 13:08:12 CEST 2015
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 at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users [1]
Links:
------
[1] http://lists.scilab.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20150827/4b29e9ac/attachment.htm>
More information about the users
mailing list