possible errors set cmds

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 554
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

possible errors set cmds

Message par compsystems » mer. avr. 01, 2020 3:26 am

Hello

possible errors

the expression is_included( D_, B_ ) currently returns 0 should return 1

is_included( D_, B_ ) [enter] true

In the following image, you can see that many outputs are confusing when shown to the public in a presentation, it is not known if it is a position, or logical value true or false, for this reason :idea: I suggest that the commands is_element? and is_included? return True/ False
is_element( set[ 2, 6 ], B_ ) [enter] true, in adition in exits others commands that return a position number/ find/ contains / member/ index

Thank you

Image

Inputs

Code : Tout sélectionner

D_ := set[ 2, 6 ]
B_ := set[ 10, 4, set[ 2, 6 ] ]
member( 8, B_ ) 
member( 10, B_ ) 
member( 4, B_ ) 
member( set[ 2, 6 ], B_ )
is_included( D_, B_ )   
is_included( set[], B_ ) 
is_included( set[11], B_ )
is_element( 8, B_ )
is_element( 10, B_ )
is_element( 4, B_ )
is_element( set[ 2, 6 ], B_ )
contains( B_, 8 )
contains( B_, 10 )
contains( B_, 4 )
contains( B_, set[ 2, 6 ] )
find( 8, B_ )
find( 10, B_ )
find( 4, B_ )
find( set[ 2, 6 ], B_ )
index( B_, 10 )
index( B_, 4 )
index( B_, set[ 2, 6 ] )
index( B_, 8 )
A_ := prepend( set[ a, b, -1 ], a ) 
eval(A_) 
find(a, prepend( set[ a, b, -1 ], a ))
find(a, A_)
find(b, prepend( set[ a, b, -1 ], a ))
find(-1, prepend( set[ a, b, -1 ], a ))

parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: possible errors set cmds

Message par parisse » jeu. avr. 02, 2020 8:21 am

compsystems a écrit :
mer. avr. 01, 2020 3:26 am
Hello

possible errors

the expression is_included( D_, B_ ) currently returns 0 should return 1
The answer of Xcas is correct, D_ is a set, it is an element of B_, but it is not a subset of B_.

compsystems
Messages : 554
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: possible errors set cmds

Message par compsystems » ven. avr. 03, 2020 1:13 am

D_ is both an element and a subset of B_, all elements of D_ are in B_, so it meets the definition of subset

Image

another suggestion is flatten only internal elements, preserving the main data type, otherwise the behavior of the SET object is lost

flatten(B_) -> flatten( set[ 10, 4, set[ 2, 6 ] ]) -> set[ 10, 4, 2, 6 ]
now if all the elements are flattened, it changes to a list type object
flatten( set[ 10, 4, 2, 6 ] ) -> [ 10, 4, 2, 6 ]

it is important in the following case, to eliminate redundant elements
flatten( set[ 1, set[1, 1, 1 ], 2 ] ) -> [1,1,2] currently
flatten( set[ 1, set[1, 1, 1 ], 2 ] ) -> set[ 1, 1, 2 ]
eval( flatten( set[ 1, set[1, 1, 1 ], 2 ] ) ) -> [ 1, 2 ]

flatten( set[1, [1], 1 ] ) -> [1,1] currently
flatten( set[1, [1], 1 ] ) -> set[1,1]

parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: possible errors set cmds

Message par parisse » ven. avr. 03, 2020 5:45 am

You are confused. If B==[10,4,[2,6]] then [2,6] is an element of B, but not a subset of B, it's [[2,6]] that is a subset of B.

compsystems
Messages : 554
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: possible errors set cmds

Message par compsystems » ven. avr. 03, 2020 9:37 pm

ok ^
B_ := set[10,4, set[2,6]]
D_: = set[2,6]
is_included( D_, flatten(B_) ) or is_included( [D_], B_ ) returns 1 =)

on flatten cmd
xcas should not operate as maximum, but I don't understand why flatten xcas cmd converts main object to list

Maxima: flatten gathers all members of set elements that are only sets.
(%i1) flatten ({a, {b}, {{c}}});
(%o1) {a, b, c} /* set */
(%i2) flatten ({a, {[a], {a}}});
(%o2) {a, [a]} /* set */
source http://maxima.sourceforge.net/docs/manu ... ma_35.html

flatten (set[a, set, set[set[c]]]) -> [a,b,c] -> set[a,b,c]
flatten ([a, [list[a], [a]]]) -> [a,a,a] -> set[a,a,a]

parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: possible errors set cmds

Message par parisse » sam. avr. 04, 2020 8:45 am

Ok, flatten will keep the list subtype in the next version.

compsystems
Messages : 554
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: possible errors set cmds

Message par compsystems » dim. mai 24, 2020 5:43 pm

flatten ([a, [list[a], [a]]]) -> set [a,a,a] not yet available in 1 Xcas 1.60-1

Répondre