| 1 | # /=====================================================================\ # | ||
| 2 | # | LaTeXML::Core::PairList | # | ||
| 3 | # | Representation of lists of pairs of numbers or dimensions | # | ||
| 4 | # |=====================================================================| # | ||
| 5 | # | Part of LaTeXML: | # | ||
| 6 | # | Public domain software, produced as part of work done by the | # | ||
| 7 | # | United States Government & not subject to copyright in the US. | # | ||
| 8 | # |---------------------------------------------------------------------| # | ||
| 9 | # | Bruce Miller <bruce.miller@nist.gov> #_# | # | ||
| 10 | # | http://dlmf.nist.gov/LaTeXML/ (o o) | # | ||
| 11 | # \=========================================================ooo==U==ooo=/ # | ||
| 12 | package LaTeXML::Core::PairList; | ||
| 13 | use strict; | ||
| 14 | use warnings; | ||
| 15 | use LaTeXML::Global; | ||
| 16 | use LaTeXML::Common::Object; | ||
| 17 | use base qw(LaTeXML::Common::Object); | ||
| 18 | use base qw(Exporter); | ||
| 19 | our @EXPORT = (qw(&PairList)); | ||
| 20 | |||
| 21 | #====================================================================== | ||
| 22 | # Exported constructor. | ||
| 23 | |||
| 24 | sub PairList { | ||
| 25 | my (@pairs) = @_; | ||
| 26 | return LaTeXML::Core::PairList->new(@pairs); } | ||
| 27 | |||
| 28 | #====================================================================== | ||
| 29 | |||
| 30 | # Note: This is candiate to be absorbed into Array perhaps... | ||
| 31 | |||
| 32 | sub new { | ||
| 33 | my ($class, @pairs) = @_; | ||
| 34 | return bless [@pairs], $class; } | ||
| 35 | |||
| 36 | sub getCount { | ||
| 37 | my ($self) = @_; | ||
| 38 | return $#{$self} + 1; } | ||
| 39 | |||
| 40 | sub getPair { | ||
| 41 | my ($self, $n) = @_; | ||
| 42 | return $$self[$n]; } | ||
| 43 | |||
| 44 | sub getPairs { | ||
| 45 | my ($self) = @_; | ||
| 46 | return @$self; } | ||
| 47 | |||
| 48 | sub ptValue { | ||
| 49 | my ($self) = @_; | ||
| 50 | return join(' ', map { $_->ptValue } @$self); } | ||
| 51 | |||
| 52 | sub pxValue { | ||
| 53 | my ($self) = @_; | ||
| 54 | return join(' ', map { $_->pxValue } @$self); } | ||
| 55 | |||
| 56 | sub toString { | ||
| 57 | my ($self) = @_; | ||
| 58 | return join(' ', map { $_->toString } @$self); } | ||
| 59 | |||
| 60 | sub toAttribute { | ||
| 61 | my ($self) = @_; | ||
| 62 | return join(' ', map { $_->toAttribute } @$self); } | ||
| 63 | |||
| 64 | sub stringify { | ||
| 65 | my ($self) = @_; | ||
| 66 | return "PairList[" . join(',', map { $_->stringify } @$self) . "]"; } | ||
| 67 | |||
| 68 | sub revert { | ||
| 69 | my ($self) = @_; | ||
| 70 | my @rev = (); | ||
| 71 | map { push(@rev, Revert($_)) } @$self; | ||
| 72 | return @rev; } | ||
| 73 | |||
| 74 | #====================================================================== | ||
| 75 | 1; | ||
| 76 | |||
| 77 | __END__ |