File Coverage

blib/lib/Arithmetic/PaperAndPencil/Label.pm
Criterion Covered Total %
statement 29 29 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 38 38 100.0


line stmt bran cond sub pod time code
1             # -*- encoding: utf-8; indent-tabs-mode: nil -*-
2              
3             package Arithmetic::PaperAndPencil::Label;
4              
5 3     3   41 use 5.38.0;
  3         12  
6 3     3   16 use utf8;
  3         6  
  3         19  
7 3     3   123 use strict;
  3         5  
  3         96  
8 3     3   15 use warnings;
  3         5  
  3         206  
9 3     3   18 use open ':encoding(UTF-8)';
  3         5  
  3         18  
10              
11             our $VERSION = '0.01';
12              
13             my %label = ('fr' => {
14             'TIT01' => 'Addition (base #1#)'
15             , 'TIT02' => 'Soustraction de #1# et #2# (base #3#)'
16             , 'TIT03' => 'Multiplication de #1# et #2#, procédé standard, base #3#'
17             , 'TIT04' => 'Multiplication de #1# et #2#, procédé avec raccourci, base #3#'
18             , 'TIT05' => 'Multiplication de #1# et #2#, avec préparation, base #3#'
19             , 'TIT06' => 'Multiplication de #1# et #2#, procédé "par jalousie" (A), base #3#'
20             , 'TIT07' => 'Multiplication de #1# et #2#, procédé "par jalousie" (B), base #3#'
21             , 'TIT08' => 'Multiplication de #1# et #2#, procédé "bateau", base #3#'
22             , 'TIT09' => 'Division de #1# par #2#, procédé standard, base #3#'
23             , 'TIT10' => 'Division de #1# par #2#, procédé standard avec triche, base #3#'
24             , 'TIT11' => 'Division de #1# par #2#, avec préparation, base #3#'
25             , 'TIT12' => 'Division de #1# par #2#, procédé "bateau", base #3#'
26             , 'TIT13' => 'Racine carrée de #1#, base #2#'
27             , 'TIT14' => 'Conversion de #1#, base #2# vers base #3#, multiplications en cascade (schéma de Horner)'
28             , 'TIT15' => 'Soustraction de #1# et #2# par addition du complément à #3#'
29             , 'TIT16' => 'Conversion de #1#, base #2# vers base #3#, divisions en cascade'
30             , 'TIT17' => 'PGCD de #1# et #2#, base #3#'
31             , 'TIT18' => 'PGCD de #1# et #2#, base #3#, avec triche'
32             , 'TIT19' => 'Multiplication de #1# et #2#, procédé "du paysan russe", base #3#'
33             , 'NXP01' => 'Changement de page'
34             , 'ADD01' => '#1# et #2#, #3#'
35             , 'ADD02' => 'et #1#, #2#'
36             , 'WRI01' => "J'écris #1#"
37             , 'WRI02' => "Je pose #1# et je retiens #2#"
38             , 'WRI03' => "Je pose #1# et je ne retiens rien"
39             , 'WRI04' => "Je pose #1#"
40             , 'WRI05' => "Je recopie la ligne #1#"
41             , 'MUL01' => '#1# fois #2#, #3#'
42             , 'MUL02' => 'Fastoche, #1# fois #2#, #3#'
43             , 'MUL03' => '#1# est pair, je barre #2#'
44             , 'CNV01' => 'Fastoche, #1# converti de la base #2# vers la base #3# donne #1#'
45             , 'CNV02' => 'La conversion de #1# donne #2#'
46             , 'CNV03' => 'Déjà converti : #1#, reste à convertir : #2#'
47             , 'SUB01' => '#1# et #2#, #3#'
48             , 'SUB02' => 'et #1#, #2#'
49             , 'SUB03' => 'Le complément à #1# de #2# est #3#'
50             , 'SUB04' => "J'élimine le chiffre de gauche et le résultat est #1#"
51             , 'DIV01' => 'En #1# combien de fois #2#, il y va #3# fois'
52             , 'DIV02' => "C'est trop fort, j'essaie #1#"
53             , 'DIV03' => "Je triche, j'essaie directement #1#"
54             , 'DIV04' => "J'abaisse le #1#"
55             , 'DIV05' => 'Fastoche, #1# divisé par 1 donne #1#, reste 0'
56             , 'DIV06' => 'Fastoche, #1# divisé par #2# donne 0, reste #1#'
57             , 'DIV07' => 'En #1# combien de fois 2, il y va #2# fois, reste #3#'
58             , 'SQR01' => 'Racine carrée de #1# égale #2#'
59             , 'SHF01' => 'Je décale #1#, ce qui donne #2#'
60             }
61             , 'en' => {
62             'TIT01' => 'Addition (radix #1#)'
63             , 'TIT02' => 'Subtraction of #1# and #2# (radix #3#)'
64             , 'TIT03' => 'Multiplication of #1# and #2#, standard processus, radix #3#'
65             , 'TIT04' => 'Multiplication of #1# and #2#, with short-cuts, radix #3#'
66             , 'TIT05' => 'Multiplication of #1# and #2#, with preparation, radix #3#'
67             , 'TIT06' => 'Multiplication of #1# and #2#, "jalousie" processus (A), radix #3#'
68             , 'TIT07' => 'Multiplication of #1# and #2#, "jalousie" processus (B), radix #3#'
69             , 'TIT08' => 'Multiplication of #1# and #2#, "boat" processus, radix #3#'
70             , 'TIT09' => 'Division of #1# by #2#, standard processus, radix #3#'
71             , 'TIT10' => 'Division of #1# by #2#, with cheating, radix #3#'
72             , 'TIT11' => 'Division of #1# by #2#, with preparation, radix #3#'
73             , 'TIT12' => 'Division of #1# by #2#, "boat" processus, radix #3#'
74             , 'TIT13' => 'Square root of #1#, radix #2#'
75             , 'TIT14' => 'Conversion of #1#, radix #2# to radix #3#, cascading multiplications (Horner scheme)'
76             , 'TIT15' => 'Subtraction of #1# and #2# by adding the #3#-complement)'
77             , 'TIT16' => 'Conversion of #1#, radix #2# to radix #3#, cascading divisions'
78             , 'TIT17' => 'GCD of #1# and #2#, radix #3#'
79             , 'TIT18' => 'GCD of #1# and #2#, radix #3#, cheating'
80             , 'TIT19' => 'Multiplication of #1# and #2#, "Russian peasant" processus, radix #3#'
81             , 'MUL01' => '#1# times #2#, #3#' # guesswork
82             }
83             )
84             ;
85              
86 42     42 1 87 our sub full_label($label, $val1, $val2, $val3, $ln) {
  42         89  
  42         85  
  42         74  
  42         70  
  42         104  
  42         124  
87 42         86 my $result;
88 42 100       235 if ($label{$ln}{$label}) {
89 32         73 $result = $label{$ln}{$label};
90             }
91             else {
92 10         29 return undef;
93             }
94 32         142 $result =~ s/\#1\#/$val1/g;
95 32         104 $result =~ s/\#2\#/$val2/g;
96 32         78 $result =~ s/\#3\#/$val3/g;
97 32         98 return $result;
98             }
99              
100             'Zéro plus zéro égale la tête à Toto'; # End of Arithmetic::PaperAndPencil::Label
101              
102             =head1 NAME
103              
104             Arithmetic::PaperAndPencil::Label -- Used internally by Arithmetic::PaperAndPencil
105              
106             =head1 VERSION
107              
108             Version 0.01
109              
110             =head1 SYNOPSIS
111              
112             use Arithmetic::PaperAndPencil::Action;
113             use Arithmetic::PaperAndPencil::Label;
114             my $action = Arithmetic::PaperAndPencil::Label->new(level => $lvl, label => ...);
115             my $line = Arithmetic::PaperAndPencil::Label::full_label($action->label
116             , $action->val1
117             , $action->val2
118             , $action->val3
119             , $lang);
120              
121             =head1 EXPORT
122              
123             None.
124              
125             =head1 SUBROUTINES/METHODS
126              
127             =head2 full_label
128              
129             Retrieves the label from the hashtable and replaces variable tags
130             (C<#1#> and similar) with the proper values.
131              
132             =head1 AUTHOR
133              
134             Jean Forget, C<< >>
135              
136             =head1 BUGS
137              
138             Please report any bugs or feature requests to C, or through
139             the web interface at L. I will be notified, and then you'll
140             automatically be notified of progress on your bug as I make changes.
141              
142              
143              
144              
145             =head1 SUPPORT
146              
147             You can find documentation for this module with the perldoc command.
148              
149             perldoc Arithmetic::PaperAndPencil
150              
151              
152             You can also look for information at:
153              
154             =over 4
155              
156             =item * RT: CPAN's request tracker (report bugs here)
157              
158             L
159              
160             =item * CPAN Ratings
161              
162             L
163              
164             =item * Search CPAN
165              
166             L
167              
168             =back
169              
170              
171             =head1 ACKNOWLEDGEMENTS
172              
173              
174             =head1 LICENSE AND COPYRIGHT
175              
176             This software is Copyright (c) 2024 by jforget.
177              
178             This is free software, licensed under:
179              
180             The Artistic License 2.0 (GPL Compatible)
181              
182              
183             =cut
184