Message Boards Message Boards

0
|
1322 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Manipulating Outputs

Posted 5 years ago

I have written some code using the For instruction. I get a sequence of sets of positive integers as outputs. I want to create a set which is the union of those output sets. How?

POSTED BY: Paul Weichsel
2 Replies
Posted 5 years ago

Maybe

SeedRandom[314];
lists = RandomInteger[10, {5, 4}]
(* {{5, 7, 3, 9}, {6, 8, 5, 10}, {2, 0, 2, 5}, {6, 0, 10, 5}, {1, 8, 0, 
  8}} *)

Flatten[lists]
(* {5, 7, 3, 9, 6, 8, 5, 10, 2, 0, 2, 5, 6, 0, 10, 5, 1, 8, 0, 8} *)

Union[Flatten[lists]]
(* {0, 1, 2, 3, 5, 6, 7, 8, 9, 10} *)
POSTED BY: Rohit Namjoshi

It would be best if you included your code so we can see details.

POSTED BY: Moderation Team
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract