Create an application that will do the following instruction. a. Getting the UNION b. Getting the INTERSECTION Example: Enter A: 1,2,3,4 Enter B: 3,4,5 Union of A&B: 1,2,3,4,5 Intersection of A&B: 3,4

How to do this any sample pls thank you

On further thought, my UNION procedure is wrong, because it does not check each item of list2 to see if it already is a member of list1 before adding it to the result. This causes undesired duplication of items.
I leave it to you to fix this.


P.S. This might help with the UNion problem ...

P.P.S. This is the one dimensional version of DISTInct ...

1 Like

Can you give the aia? Thank you I'll will try to fix it

Here are some draggable pieces of code you can use, to get you started.

These blocks can be dragged directly into your Blocks Editor workspace.

UNION can be built from

  • 2 copy list blocks
  • an list APPEND block
  • a call to the UNIQUE function against the appended copies.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.