Old Russian measure of length: Difference between revisions

Content added Content deleted
(Add Factor example)
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 4: Line 4:


See [https://en.wikipedia.org/wiki/Obsolete_Russian_units_of_measurement#Length Old Russian measure of length]
See [https://en.wikipedia.org/wiki/Obsolete_Russian_units_of_measurement#Length Old Russian measure of length]

=={{header|МК-61/52}}==
<lang>П7 1 0 0 * П8 1 ВП 5 /
П9 ИП7 1 0 6 7 / П0 5 0
0 * ПC 3 * ПA 1 6 * ПB
С/П ПB 1 6 / ПA 3 / ПC 5
0 0 / П0 1 0 6 7 / БП
00</lang>

''Instruction:''
l, meters = РX В/О С/П; l, vershoks = БП 3 1 С/П; l, arshins = РX БП 3 5 С/П; l, sazhens = РX БП 3 8 С/П; l, versts = РX БП 4 3 С/П; РX = РB = l, vershoks; РA = l, arshins; РB = l, versts; РC = l, sazhens; Р7 = l, meters; Р8 = l, centimeters; Р9 = l, kilometers.

''Example:''
100 m = 2249,2971 vershoks = 140,58107 arshins = 46,860366 sazhens = 0,093790712 versts;
3 vershoks = 13,3375 cm; 2 sazhens = 96 vershoks = 6 arshins = 4,268 m; 1 verst = 1,067 km.


=={{header|AWK}}==
=={{header|AWK}}==
Line 1,094: Line 1,079:
Do another one y/n : n
Do another one y/n : n
</pre>
</pre>

=={{header|МК-61/52}}==
<lang>П7 1 0 0 * П8 1 ВП 5 /
П9 ИП7 1 0 6 7 / П0 5 0
0 * ПC 3 * ПA 1 6 * ПB
С/П ПB 1 6 / ПA 3 / ПC 5
0 0 / П0 1 0 6 7 / БП
00</lang>

''Instruction:''
l, meters = РX В/О С/П; l, vershoks = БП 3 1 С/П; l, arshins = РX БП 3 5 С/П; l, sazhens = РX БП 3 8 С/П; l, versts = РX БП 4 3 С/П; РX = РB = l, vershoks; РA = l, arshins; РB = l, versts; РC = l, sazhens; Р7 = l, meters; Р8 = l, centimeters; Р9 = l, kilometers.

''Example:''
100 m = 2249,2971 vershoks = 140,58107 arshins = 46,860366 sazhens = 0,093790712 versts;
3 vershoks = 13,3375 cm; 2 sazhens = 96 vershoks = 6 arshins = 4,268 m; 1 verst = 1,067 km.


=={{header|Perl}}==
=={{header|Perl}}==
Line 1,167: Line 1,167:
kilometer: 7.4676
kilometer: 7.4676
versta: 7</pre>
versta: 7</pre>

=={{header|Perl 6}}==
{{Works with|rakudo|2015.12}}
Fairly straightfoward. Define a hash of conversion factors then apply them. Makes no attempt to do correct pluralization because I have no idea what the correct plurals are and little interest in researching them. Conversion factors from Wikipedia: [[wp:Obsolete_Russian_units_of_measurement#Length|Obsolete Russian units of measurement]].

<lang perl6>convert(1, 'meter');

say '*' x 40, "\n";

convert(1, 'milia');

sub convert (Real $magnitude, $unit) {
my %factor =
tochka => 0.000254,
liniya => 0.00254,
diuym => 0.0254,
vershok => 0.04445,
piad => 0.1778,
fut => 0.3048,
arshin => 0.7112,
sazhen => 2.1336,
versta => 1066.8,
milia => 7467.6,
centimeter => 0.01,
meter => 1.0,
kilometer => 1000.0,
;

my $meters = $magnitude * %factor{$unit.lc};

say "$magnitude $unit to:\n", '_' x 40;

printf "%10s: %s\n", $_, $meters / %factor{$_} unless $_ eq $unit.lc
for %factor.keys.sort:{ +%factor{$_} }
}
</lang>

<pre>
1 meter to:
________________________________________
tochka: 3937.007874
liniya: 393.700787
centimeter: 100
diuym: 39.370079
vershok: 22.497188
piad: 5.624297
fut: 3.280840
arshin: 1.406074
sazhen: 0.468691
kilometer: 0.001
versta: 0.000937
milia: 0.000134
****************************************

1 milia to:
________________________________________
tochka: 29400000
liniya: 2940000
centimeter: 746760
diuym: 294000
vershok: 168000
piad: 42000
fut: 24500
arshin: 10500
meter: 7467.6
sazhen: 3500
kilometer: 7.4676
versta: 7
</pre>


=={{header|Phix}}==
=={{header|Phix}}==
Line 1,429: Line 1,360:
(show 'milia)
(show 'milia)
</lang>
</lang>

=={{header|Raku}}==
(formerly Perl 6)
{{Works with|rakudo|2015.12}}
Fairly straightfoward. Define a hash of conversion factors then apply them. Makes no attempt to do correct pluralization because I have no idea what the correct plurals are and little interest in researching them. Conversion factors from Wikipedia: [[wp:Obsolete_Russian_units_of_measurement#Length|Obsolete Russian units of measurement]].

<lang perl6>convert(1, 'meter');

say '*' x 40, "\n";

convert(1, 'milia');

sub convert (Real $magnitude, $unit) {
my %factor =
tochka => 0.000254,
liniya => 0.00254,
diuym => 0.0254,
vershok => 0.04445,
piad => 0.1778,
fut => 0.3048,
arshin => 0.7112,
sazhen => 2.1336,
versta => 1066.8,
milia => 7467.6,
centimeter => 0.01,
meter => 1.0,
kilometer => 1000.0,
;

my $meters = $magnitude * %factor{$unit.lc};

say "$magnitude $unit to:\n", '_' x 40;

printf "%10s: %s\n", $_, $meters / %factor{$_} unless $_ eq $unit.lc
for %factor.keys.sort:{ +%factor{$_} }
}
</lang>

<pre>
1 meter to:
________________________________________
tochka: 3937.007874
liniya: 393.700787
centimeter: 100
diuym: 39.370079
vershok: 22.497188
piad: 5.624297
fut: 3.280840
arshin: 1.406074
sazhen: 0.468691
kilometer: 0.001
versta: 0.000937
milia: 0.000134
****************************************

1 milia to:
________________________________________
tochka: 29400000
liniya: 2940000
centimeter: 746760
diuym: 294000
vershok: 168000
piad: 42000
fut: 24500
arshin: 10500
meter: 7467.6
sazhen: 3500
kilometer: 7.4676
versta: 7
</pre>


=={{header|REXX}}==
=={{header|REXX}}==
Line 1,665: Line 1,666:


}</lang>
}</lang>

=={{header|Sidef}}==
=={{header|Sidef}}==
{{trans|Perl 6}}
{{trans|Perl 6}}