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=/ #
12package LaTeXML::Core::PairList;
13use strict;
14use warnings;
15use LaTeXML::Global;
16use LaTeXML::Common::Object;
17use base qw(LaTeXML::Common::Object);
18use base qw(Exporter);
19our @EXPORT = (qw(&PairList));
20
21#======================================================================
22# Exported constructor.
23
24sub 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
32sub new {
33  my ($class, @pairs) = @_;
34  return bless [@pairs], $class; }
35
36sub getCount {
37  my ($self) = @_;
38  return $#{$self} + 1; }
39
40sub getPair {
41  my ($self, $n) = @_;
42  return $$self[$n]; }
43
44sub getPairs {
45  my ($self) = @_;
46  return @$self; }
47
48sub ptValue {
49  my ($self) = @_;
50  return join(' ', map { $_->ptValue } @$self); }
51
52sub pxValue {
53  my ($self) = @_;
54  return join(' ', map { $_->pxValue } @$self); }
55
56sub toString {
57  my ($self) = @_;
58  return join(' ', map { $_->toString } @$self); }
59
60sub toAttribute {
61  my ($self) = @_;
62  return join(' ', map { $_->toAttribute } @$self); }
63
64sub stringify {
65  my ($self) = @_;
66  return "PairList[" . join(',', map { $_->stringify } @$self) . "]"; }
67
68sub revert {
69  my ($self) = @_;
70  my @rev = ();
71  map { push(@rev, Revert($_)) } @$self;
72  return @rev; }
73
74#======================================================================
751;
76
77__END__
78
79=pod
80
81=head1 NAME
82
83C<LaTeXML::Core::PairList> - representation of lists of pairs of numerical things
84
85=head1 DESCRIPTION
86
87represents lists of pairs of numerical things, coordinates or such.
88Candidate for removal!
89
90=head2 Exported functions
91
92=over 4
93
94=item C<< $pair = PairList(@pairs); >>
95
96Creates an object representing a list of pairs of numbers;
97Not a part of TeX, but useful for graphical objects.
98
99=back
100
101=head1 AUTHOR
102
103Bruce Miller <bruce.miller@nist.gov>
104
105=head1 COPYRIGHT
106
107Public domain software, produced as part of work done by the
108United States Government & not subject to copyright in the US.
109
110=cut
111
112