| … | |
… | |
| 25 | my $constant = shift; my $paren = shift; |
25 | my $constant = shift; my $paren = shift; |
| 26 | my $entryType = shift || $Value::Type{unknown}; |
26 | my $entryType = shift || $Value::Type{unknown}; |
| 27 | my $open = shift || ''; my $close = shift || ''; |
27 | my $open = shift || ''; my $close = shift || ''; |
| 28 | my $context = $equation->{context}; |
28 | my $context = $equation->{context}; |
| 29 | my $parens = $context->{parens}; my $list; |
29 | my $parens = $context->{parens}; my $list; |
| 30 | |
30 | |
| 31 | if ($paren && $close && $paren->{formInterval}) { |
31 | if ($paren && $close && $paren->{formInterval}) { |
| 32 | $paren = $parens->{interval} |
32 | $paren = $parens->{interval} |
| 33 | if ($paren->{close} ne $close || (scalar(@{$coords}) == 2 && |
33 | if ($paren->{close} ne $close || (scalar(@{$coords}) == 2 && |
| 34 | ($coords->[0]->{isInfinite} || $coords->[1]->{isInfinite})) || |
34 | ($coords->[0]->{isInfinite} || $coords->[1]->{isInfinite})) || |
| 35 | (scalar(@{$coords}) == 1 && $coords->[0]->{isInfinite})); |
35 | (scalar(@{$coords}) == 1 && $coords->[0]->{isInfinite})); |
| 36 | } |
36 | } |
| 37 | my $type = Value::Type($paren->{type},scalar(@{$coords}),$entryType, |
37 | my $type = Value::Type($paren->{type},scalar(@{$coords}),$entryType, |
| 38 | list => 1, formMatrix => $paren->{formMatrix}); |
38 | list => 1, formMatrix => $paren->{formMatrix}); |
| 39 | if ($type->{name} ne 'Interval') { |
39 | if ($type->{name} ne 'Interval' && ($type->{name} ne 'Set' || $type->{length} != 0)) { |
| 40 | if ($paren->{formMatrix} && $entryType->{formMatrix}) {$type->{name} = 'Matrix'} |
40 | if ($paren->{formMatrix} && $entryType->{formMatrix}) {$type->{name} = 'Matrix'} |
| 41 | elsif ($entryType->{name} eq 'unknown') { |
41 | elsif ($entryType->{name} eq 'unknown') { |
| 42 | if ($paren->{formList}) {$type->{name} = 'List'} |
42 | if ($paren->{formList}) {$type->{name} = 'List'} |
| 43 | elsif ($type->{name} eq 'Point') { |
43 | elsif ($type->{name} eq 'Point') { |
| 44 | $equation->Error("Entries in a Matrix must be of the same type and length")} |
44 | $equation->Error("Entries in a Matrix must be of the same type and length")} |
| … | |
… | |
| 226 | sub perl { |
226 | sub perl { |
| 227 | my $self = shift; my $parens = shift; my $matrix = shift; |
227 | my $self = shift; my $parens = shift; my $matrix = shift; |
| 228 | my $perl; my @p = (); |
228 | my $perl; my @p = (); |
| 229 | foreach my $x (@{$self->{coords}}) {push(@p,$x->perl)} |
229 | foreach my $x (@{$self->{coords}}) {push(@p,$x->perl)} |
| 230 | $perl = 'new Value::'.$self->type.'('.join(',',@p).')'; |
230 | $perl = 'new Value::'.$self->type.'('.join(',',@p).')'; |
| 231 | $perl = 'Closed('.$perl.')' |
231 | $perl = "${perl}->with(open=>'$self->{open}',close=>'$self->{close}')" |
| 232 | if $self->{canBeInterval} && $self->{open}.$self->{close} eq '[]'; |
232 | if $self->{canBeInterval} && $self->{open}.$self->{close} eq '[]'; |
| 233 | $perl = '('.$perl.')' if $parens; |
233 | $perl = '('.$perl.')' if $parens; |
| 234 | return $perl; |
234 | return $perl; |
| 235 | } |
235 | } |
| 236 | |
236 | |
| … | |
… | |
| 242 | use Parser::List::Point; |
242 | use Parser::List::Point; |
| 243 | use Parser::List::Vector; |
243 | use Parser::List::Vector; |
| 244 | use Parser::List::Matrix; |
244 | use Parser::List::Matrix; |
| 245 | use Parser::List::List; |
245 | use Parser::List::List; |
| 246 | use Parser::List::Interval; |
246 | use Parser::List::Interval; |
|
|
247 | use Parser::List::Set; |
| 247 | use Parser::List::AbsoluteValue; |
248 | use Parser::List::AbsoluteValue; |
| 248 | |
249 | |
| 249 | ######################################################################### |
250 | ######################################################################### |
| 250 | |
251 | |
| 251 | 1; |
252 | 1; |