| … | |
… | |
| 258 | return unless $ans->{studentsMustReduceUnions} && |
258 | return unless $ans->{studentsMustReduceUnions} && |
| 259 | $ans->{showUnionReduceWarnings} && |
259 | $ans->{showUnionReduceWarnings} && |
| 260 | !$ans->{isPreview} && !Value::isFormula($student); |
260 | !$ans->{isPreview} && !Value::isFormula($student); |
| 261 | if ($student->type eq 'Union' && $student->length >= 2) { |
261 | if ($student->type eq 'Union' && $student->length >= 2) { |
| 262 | my $reduced = $student->reduce; |
262 | my $reduced = $student->reduce; |
| 263 | return "Your$nth union can be written in a simpler form" |
263 | return "Your$nth union can be written without overlaps" |
| 264 | unless $reduced->type eq 'Union' && $reduced->length == $student->length; |
264 | unless $reduced->type eq 'Union' && $reduced->length == $student->length; |
| 265 | my @R = $reduced->sort->value; |
265 | my @R = $reduced->sort->value; |
| 266 | my @S = $student->sort->value; |
266 | my @S = $student->sort->value; |
| 267 | foreach my $i (0..$#R) { |
267 | foreach my $i (0..$#R) { |
| 268 | return "Your$nth union can be written in a simpler form" |
268 | return "Your$nth union can be written without overlaps" |
| 269 | unless $R[$i] == $S[$i] && $R[$i]->length == $S[$i]->length; |
269 | unless $R[$i] == $S[$i] && $R[$i]->length == $S[$i]->length; |
| 270 | } |
270 | } |
| 271 | } elsif ($student->type eq 'Set' && $student->length >= 2) { |
271 | } elsif ($student->type eq 'Set' && $student->length >= 2) { |
| 272 | return "Your$nth set should have no repeated elements" |
272 | return "Your$nth set should have no repeated elements" |
| 273 | unless $student->reduce->length == $student->length; |
273 | unless $student->reduce->length == $student->length; |