The Python language considers a complete string or the elements of a string as an object of true value,
Does BP consider it convenient for Xcas to work in the same way as Python does in this part? See example # 3.1
that is, each character, since it has its numerical equivalent, then they are values that can be considered true
Code : Tout sélectionner
#cas
def all( iterable ):
for element_ in iterable:
if not element_:
return False
return True
#end
lst1 := [ -5.8, -1, 1, 3.5, 4, 10 ];
print( all( lst1 ) ) [enter] returns
True
example # 2
lst1 := [ -5.8, -1, 1, 3.5, 4, 10, 0 ];
print( all( lst1 ) ) [enter] returns
False
example # 3
tbl1 := table( 65: "A", 97: "a", 215: "×", 247: "÷" );
print( all( tbl1 ) ) [enter]
True
example # 3.1
tbl1 := table("65": "A", "97": "a")
print( all( tbl1 ) ) [enter]
"Error"