Power set: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 43: Line 43:
add_element
add_element
importing
importing
i_element type any
i_element type any
exporting
returning
e_set type any table,
value(r_set) type ref to set,


remove_element
remove_element
importing
importing
i_element type any,
i_element type any
returning
value(r_set) type ref to set,


contains_element
contains_element
Line 107: Line 109:


method set~add_element.
method set~add_element.
check not line_exists( me->elements[ table_line = i_element ] ).
if not line_exists( me->elements[ table_line = i_element ] ).
append i_element to me->elements.
append i_element to me->elements.
endif.

r_set = me.
endmethod.
endmethod.




method set~remove_element.
method set~remove_element.
check line_exists( me->elements[ table_line = i_element ] ).
if line_exists( me->elements[ table_line = i_element ] ).
delete me->elements where table_line = i_element.
delete me->elements where table_line = i_element.
endif.

r_set = me.
endmethod.
endmethod.


Line 196: Line 204:
start-of-selection.
start-of-selection.
data(set1) = new string_set( ).
data(set1) = new string_set( ).
data(set2) = new string_set( value stringtab( ( `∅` ) ) ).
data(set2) = new string_set( ).
data(set3) = new string_set( value stringtab( ( `1` ) ( `2` ) ( `3` ) ( `3` ) ( `4` ) ( `4` ) ( `4` ) ) ).
data(set3) = new string_set( ).


write |𝑷( { set1->set~stringify( ) } ) ->|.
write |𝑷( { set1->set~stringify( ) } ) ->|.
Line 203: Line 211:
new-line.
new-line.


set2->set~add_element( `∅` ).
write |𝑷( { set2->set~stringify( ) } ) ->|.
write |𝑷( { set2->set~stringify( ) } ) ->|.
write set2->build_powerset( )->set~stringify( ).
write set2->build_powerset( )->set~stringify( ).
new-line.
new-line.


set3->set~add_element( `1` )->add_element( `2` )->add_element( `3` )->add_element( `3`
)->add_element( `4` )->add_element( `4` )->add_element( `4` ).
write |𝑷( { set3->set~stringify( ) } ) ->|.
write |𝑷( { set3->set~stringify( ) } ) ->|.
write set3->build_powerset( )->set~stringify( ).
write set3->build_powerset( )->set~stringify( ).