Old Russian measure of length: Difference between revisions

m
imported>Arakov
 
(14 intermediate revisions by 10 users not shown)
Line 515:
</pre>
 
=={{header|BBC BASIC}}==
==={{header|BASIC256}}===
<syntaxhighlight lang="basic">arraybase 1
dim units = {"tochka", "liniya", "dyuim", "vershok", "piad", "fut", "arshin", "sazhen", "versta", "milia", "centimeter", "meter", "kilometer"}
# all expressed in centimeters
dim convs = {0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, 71.12, 213.36, 10668, 74676, 1, 100, 10000}
 
do
cls
print
for i = 1 to units[?]
print rjust(string(i),2); " "; units[i]
next
print
do
input "Please choose a unit 1 to 13 : ", unit
until unit >= 1 and unit <= 13
print
do
input "Now enter a value in that unit : ", value
until value >= 0
print
print "The equivalent in the remaining units is : "
print
for i = 1 to units[?]
if i = unit then continue for
print " "; units[i], " : "; value * convs[unit] / convs[i]
next
print
do
input "Do another one y/n : ", yn
yn = lower(yn)
until yn = "y" or yn = "n"
until yn = "n"</syntaxhighlight>
{{out}}
<pre>Same as Run BASIC entry.</pre>
 
==={{header|BBC BASIC}}===
<syntaxhighlight lang="bbcbasic">REM >oldrussian
@% = &90E
Line 570 ⟶ 607:
2800 liniya
28000 tochka</pre>
 
 
==={{header|FreeBASIC}}===
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
Dim units(1 To 13) As String = {"tochka", "liniya", "dyuim", "vershok", "piad", "fut", _
"arshin", "sazhen", "versta", "milia", _
"centimeter", "meter", "kilometer"}
 
' all expressed in centimeters
Dim convs(1 To 13) As Single = {0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, _
71.12, 213.36, 10668, 74676, _
1, 100, 10000}
Dim unit As Integer
Dim value As Single
Dim yn As String
 
Do
Shell("cls")
Print
For i As Integer = 1 To 13
Print Using "##"; i;
Print " "; units(i)
Next
Print
Do
Input "Please choose a unit 1 to 13 : "; unit
Loop Until unit >= 1 AndAlso unit <= 13
Print
Do
Input "Now enter a value in that unit : "; value
Loop Until value >= 0
Print
Print "The equivalent in the remaining units is : "
Print
For i As Integer = 1 To 13
If i = unit Then Continue For
Print " "; units(i), " : "; value * convs(unit) / convs(i)
Next
Print
Do
Input "Do another one y/n : "; yn
yn = LCase(yn)
Loop Until yn = "y" OrElse yn = "n"
Loop Until yn = "n"
End</syntaxhighlight>
Sample input/output:
{{out}}
<pre>
 
1 tochka
2 liniya
3 dyuim
4 vershok
5 piad
6 fut
7 arshin
8 sazhen
9 versta
10 milia
11 centimeter
12 meter
13 kilometer
 
Please choose a unit 1 to 13 : ? 13
 
Now enter a value in that unit : ? 1
 
The equivalent in the remaining units is :
 
tochka : 393700.8
liniya : 39370.08
dyuim : 3937.008
vershok : 2249.719
piad : 562.4297
fut : 328.084
arshin : 140.6074
sazhen : 46.86914
versta : 0.9373828
milia : 0.1339118
centimeter : 10000
meter : 100
 
Do another one y/n : ? n
</pre>
 
==={{header|Gambas}}===
<syntaxhighlight lang="vbnet">Public Sub Main()
Dim units As String[] = ["tochka", "liniya", "dyuim", "vershok", "piad", "fut", "arshin", "sazhen", "versta", "milia", "centimeter", "meter", "kilometer"]
' all expressed in centimeters
Dim convs As Single[] = [0.254, 0.254, 2.54, 4.445, 17.78, 30.48, 71.12, 213.36, 10668, 74676, 1, 100, 10000]
Dim i, unit As Integer
Dim value As Single
Dim yn As String
Do
Shell("clear")
Print
For i = 1 To units.count
Print Format$(i, "##"); " "; units[i - 1]
Next
Print "\nPlease choose a unit 1 to 13 : "
Do
Input unit
Loop Until unit >= 1 And unit <= 13
Print "\nNow enter a value in that unit : "
Do
Input value
Loop Until value >= 0
Print "\nThe equivalent in the remaining units is : \n"
For i = 0 To units.count - 1
If i = unit - 1 Then Continue 'For
Print units[i]; Space$(10 - Len(units[i]));
Print " : "; value * convs[unit - 1] / convs[i]
Next
Print "\nDo another one y/n : "
Do
Input yn
yn = LCase(yn)
Loop Until yn = "y" Or yn = "n"
Loop Until yn = "n"
End</syntaxhighlight>
{{out}}
<pre>Similar as FreeBASIC entry.</pre>
 
==={{header|QBasic}}===
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
<syntaxhighlight lang="qbasic">DIM units(1 TO 13) AS STRING
FOR i = LBOUND(units) TO UBOUND(units)
READ units(i)
NEXT i
DATA "tochka", "liniya", "dyuim", "vershok", "piad", "fut", "arshin", "sazhen", "versta", "milia", "centimeter", "meter", "kilometer"
 
' all expressed in centimeters
DIM convs(1 TO 13) AS SINGLE
FOR i = 1 TO 13
READ convs(i)
NEXT i
DATA 0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, 71.12, 213.36, 10668, 74676, 1, 100, 10000
DIM unit AS INTEGER
DIM value AS SINGLE
DIM yn AS STRING
 
DO
CLS
PRINT
FOR i = 1 TO 13
PRINT USING "## "; i;
PRINT units(i)
NEXT i
PRINT
DO
INPUT "Please choose a unit 1 to 13 : ", unit
LOOP UNTIL unit >= 1 AND unit <= 13
PRINT
DO
INPUT "Now enter a value in that unit : ", value
LOOP UNTIL value >= 0
PRINT
PRINT "The equivalent in the remaining units is : "
PRINT
FOR i = 1 TO 13
IF i <> unit THEN PRINT " "; units(i), " : "; value * convs(unit) / convs(i)
NEXT i
PRINT
DO
INPUT "Do another one y/n : ", yn
yn = LCASE$(yn)
LOOP UNTIL yn = "y" OR yn = "n"
LOOP UNTIL yn = "n"</syntaxhighlight>
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
==={{header|True BASIC}}===
<syntaxhighlight lang="qbasic">DIM units$(1 TO 13)
FOR i = LBOUND(units$) TO UBOUND(units$)
READ units$(i)
NEXT i
DATA "tochka", "liniya", "dyuim", "vershok", "piad", "fut", "arshin", "sazhen", "versta", "milia", "centimeter", "meter", "kilometer"
 
! all expressed in centimeters
DIM convs(1 TO 13)
FOR i = 1 TO 13
READ convs(i)
NEXT i
DATA 0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, 71.12, 213.36, 10668, 74676, 1, 100, 10000
 
DO
CLEAR
PRINT
FOR i = 1 TO 13
PRINT USING "## ": i;
PRINT units$(i)
NEXT i
PRINT
DO
INPUT prompt "Please choose a unit 1 to 13 : ": unit
LOOP UNTIL unit >= 1 AND unit <= 13
PRINT
DO
INPUT prompt "Now enter a value! in that unit : ": value
LOOP UNTIL value >= 0
PRINT
PRINT "The equivalent in the remaining units is : "
PRINT
FOR i = 1 TO 13
IF i <> unit THEN PRINT " "; units$(i), " : "; value*convs(unit)/convs(i)
NEXT i
PRINT
DO
INPUT prompt "Do another one y/n : ": yn$
LET yn$ = LCASE$(yn$)
LOOP UNTIL yn$ = "y" OR yn$ = "n"
LOOP UNTIL yn$ = "n"
END</syntaxhighlight>
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
==={{header|XBasic}}===
{{works with|Windows XBasic}}
<syntaxhighlight lang="qbasic">PROGRAM "progname"
VERSION "0.0000"
 
DECLARE FUNCTION Entry ()
 
FUNCTION Entry ()
 
DIM units$[14]
units$[1] = "tochka " : units$[2] = "liniya " : units$[3] = "dyuim "
units$[4] = "vershok " : units$[5] = "piad " : units$[6] = "fut "
units$[7] = "arshin " : units$[8] = "sazhen " : units$[9] = "versta "
units$[10] = "milia " : units$[11] = "centimeter" : units$[12] = "meter "
units$[13] = "kilometer "
 
' all expressed in centimeters
DIM convs![14]
convs![1] = 0.0254 : convs![2] = 0.254 : convs![3] = 2.54
convs![4] = 4.445 : convs![5] = 17.78 : convs![6] = 30.48
convs![7] = 71.12 : convs![8] = 213.36 : convs![9] = 10668
convs![10] = 74676 : convs![11] = 1 : convs![12] = 100 : convs![13] = 10000
 
DO
PRINT
FOR i = 1 TO 13
PRINT FORMAT$("##",i); " "; units$[i]
NEXT i
DO
unit = UBYTE(INLINE$("\nPlease choose a unit 1 to 13 : "))
LOOP UNTIL unit >= 1 AND unit <= 13
DO
value = USHORT(INLINE$("\nNow enter a value in that unit : "))
LOOP UNTIL value >= 0
 
PRINT
PRINT "The equivalent in the remaining units is : "
PRINT
FOR i = 1 TO 13
IF i <> unit THEN PRINT " "; units$[i], " : "; value * convs![unit] / convs![i]
NEXT i
DO
yn$ = LCASE$(INLINE$("\nDo another one y/n : "))
LOOP UNTIL (yn$ = "y") OR (yn$ = "n")
LOOP UNTIL yn$ = "n"
 
END FUNCTION
END PROGRAM</syntaxhighlight>
{{out}}
<pre>Similar as FreeBASIC entry.</pre>
 
==={{header|uBasic/4tH}}===
This program uses a command prompt. It will accept queries as long as the order ''"quantity, from unit, to unit"'' is preserved. '''EXIT''' will leave the program. Note all arithmetic is done in fixed point math, so some rounding errors are unavoidable.
<syntaxhighlight lang="basic">Do ' get in command loop
t := "" ' no token
n = Info ("nil") ' units are undefined
f = _Fmul ' first, a multiplication
o = Ask("> ") ' show the prompt
' strip trailing spaces
For x = Len (o) While Peek(o, Set(x, x-1)) = Ord(" ") : o = Clip(o, 1) : Next
 
Do While Len (o) ' if there is something left to parse
t = FUNC(_Parse (" ")) ' get the token
If Val (t) # Info ("nil") Then n = FUNC (_Ntof (Val (t)))
l = Name (t) ' is it a number, set it
If Line (l) Then n = FUNC (l (f, n)) : f = _Fdiv
Loop ' if it's a function, execute it
Until n = Info ("nil") ' display the result
Print Show (Str ("+?.####", FUNC(_Ftoi (n))));" ";Show (t)
Loop
 
End
 
_Parse ' parse string and get token
Param (1)
Local (3)
 
Do ' get only complete tokens
If Set(b@, Find(o, a@)) < 0 Then
c@ := o : o := "" ' last token, we're done
Else ' get the next token
c@ = Clip (o, Len(o) - b@) : o = Chop (o, b@+1)
EndIf
Until Len (c@) : Loop
 
Return (c@) ' return token
 
Rem 'arshin' = 0.7112, 'centimeter' = 0.01, 'diuym' = 0.0254,
Rem 'fut' = 0.3048, 'kilometer' = 1000.0, 'liniya' = 0.00254,
Rem 'meter' = 1.0, 'milia' = 7467.6, 'piad' = 0.1778,
Rem 'sazhen' = 2.1336, 'tochka' = 0.000254, 'vershok' = 0.04445,
Rem 'versta' = 1066.8
 
_arshin Param (2) : Return (FUNC(a@(b@, FUNC(_Itof (711200)))))
_centimeter Param (2) : Return (FUNC(a@(b@, FUNC(_Ntof (1)))))
_diuym Param (2) : Return (FUNC(a@(b@, FUNC(_Itof (25400)))))
_fut Param (2) : Return (FUNC(a@(b@, FUNC(_Itof (304800)))))
_kilometer Param (2) : Return (FUNC(a@(b@, FUNC(_Ntof (100000)))))
_liniya Param (2) : Return (FUNC(a@(b@, FUNC(_Itof (2540)))))
_meter Param (2) : Return (FUNC(a@(b@, FUNC(_Ntof (100)))))
_milia Param (2) : Return (FUNC(a@(b@, FUNC(_Ntof (746760)))))
_piad Param (2) : Return (FUNC(a@(b@, FUNC(_Itof (177800)))))
_sazhen Param (2) : Return (FUNC(a@(b@, FUNC(_Itof (2133600)))))
_tochka Param (2) : Return (FUNC(a@(b@, FUNC(_Itof (254)))))
_vershok Param (2) : Return (FUNC(a@(b@, FUNC(_Itof (44450)))))
_versta Param (2) : Return (FUNC(a@(b@, FUNC(_Ntof (106680)))))
_exit Param (2) : Return (Info ("nil"))
 
_Fmul Param (2) : Return ((a@*b@)/16384)
_Fdiv Param (2) : Return ((a@*16384)/b@)
_Ftoi Param (1) : Return ((10000*a@)/16384)
_Itof Param (1) : Return ((16384*a@)/10000)
_Ntof Param (1) : Return (a@*16384)
</syntaxhighlight>
{{Out}}
<pre>> convert 1 meter to fut
3.2808 fut
> convert 10 diuym to centimeter
25.3997 centimeter
> how much is 1 fut in diuym
12.0000 diuym
> 20 diuym in tochka
2000.7211 tochka
> 1 milia = versta
7.0000 versta
> exit
 
0 OK, 0:1014 </pre>
 
==={{header|Yabasic}}===
<syntaxhighlight lang="basic">dim units$(14)
units$(1) = "tochka" : units$(2) = "liniya" : units$(3) = "dyuim"
units$(4) = "vershok" : units$(5) = "piad" : units$(6) = "fut"
units$(7) = "arshin" : units$(8) = "sazhen" : units$(9) = "versta"
units$(10) = "milia" : units$(11) = "centimeter" : units$(12) = "meter"
units$(13) = "kilometer"
 
// all expressed in centimeters
dim convs(14)
convs(1) = 0.0254 : convs(2) = 0.254 : convs(3) = 2.54
convs(4) = 4.445 : convs(5) = 17.78 : convs(6) = 30.48
convs(7) = 71.12 : convs(8) = 213.36 : convs(9) = 10668
convs(10) = 74676 : convs(11) = 1 : convs(12) = 100 : convs(13) = 10000
 
repeat
clear screen
print
for i = 1 to arraysize(units$(), 1) - 1
print i using ("##"), " ", units$(i)
next
print
repeat
input "Please choose a unit 1 to 13 : " unit
until unit >= 1 and unit <= 13
print
repeat
input "Now enter a value in that unit : " value
until value >= 0
print "\nThe equivalent in the remaining units is : \n"
for i = 1 to 13
if i = unit continue
print " ", units$(i), "\t : ", value * convs(unit) / convs(i)
next
print
repeat
input "Do another one y/n : " yn$
yn$ = lower$(yn$)
until yn$ = "y" or yn$ = "n"
until yn$ = "n"
end</syntaxhighlight>
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
=={{header|C}}==
Line 884 ⟶ 1,318:
until yn.toLower = 'n';
end.</syntaxhighlight>
 
=={{header|EasyLang}}==
{{trans|Gambas}}
<syntaxhighlight>
units$[] = [ "tochka" "liniya" "dyuim" "vershok" "piad" "fut" "arshin" "sazhen" "versta" "milia" "centimeter" "meter" "kilometer" ]
convs[] = [ 0.254 0.254 2.54 4.445 17.78 30.48 71.12 213.36 10668 74676 1 100 10000 ]
for i to len units$[]
print i & ") " & units$[i]
.
print ""
write "Please choose a unit (1 to 13): "
repeat
unit = number input
until unit >= 1 and unit <= 13
.
print unit
write "Now enter a value in that unit: "
repeat
value = -1
value = number input
print value
until value >= 0
.
print value
print ""
print value & " " & units$[unit] & " are"
print ""
for i to len units$[]
if i <> unit
print value * convs[unit] / convs[i] & " " & units$[i]
.
.
</syntaxhighlight>
 
=={{header|Elena}}==
{{trans|Julia}}
ELENA 56.2x:
<syntaxhighlight lang="elena">import system'collections;
import system'routines;
Line 910 ⟶ 1,377:
{
if (program_arguments.Length != 3)
{ console.writeLine:("need two arguments - number then units"); AbortException.raise() };
real value := program_arguments[1].toReal();
Line 917 ⟶ 1,384:
{
console.printLine("only following units are supported:",
unit2mult.selectBy::(x=>x.Item1).asEnumerable());
AbortException.raise()
Line 924 ⟶ 1,391:
console.printLine(value," ",unit," to:");
 
unit2mult.forEach::(u,mlt)
{
console.printPaddingLeft(30, u, ":").printLine(value * unit2mult[unit] / mlt)
Line 1,128 ⟶ 1,595:
10.000 arshin</pre>
 
=={{header|FreeBASIC}}==
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
Dim units(1 To 13) As String = {"tochka", "liniya", "dyuim", "vershok", "piad", "fut", _
"arshin", "sazhen", "versta", "milia", _
"centimeter", "meter", "kilometer"}
 
' all expressed in centimeters
Dim convs(1 To 13) As Single = {0.0254, 0.254, 2.54, 4.445, 17.78, 30.48, _
71.12, 213.36, 10668, 74676, _
1, 100, 10000}
Dim unit As Integer
Dim value As Single
Dim yn As String
 
Do
Shell("cls")
Print
For i As Integer = 1 To 13
Print Using "##"; i;
Print " "; units(i)
Next
Print
Do
Input "Please choose a unit 1 to 13 : "; unit
Loop Until unit >= 1 AndAlso unit <= 13
Print
Do
Input "Now enter a value in that unit : "; value
Loop Until value >= 0
Print
Print "The equivalent in the remaining units is : "
Print
For i As Integer = 1 To 13
If i = unit Then Continue For
Print " "; units(i), " : "; value * convs(unit) / convs(i)
Next
Print
Do
Input "Do another one y/n : "; yn
yn = LCase(yn)
Loop Until yn = "y" OrElse yn = "n"
Loop Until yn = "n"
End</syntaxhighlight>
Sample input/output:
{{out}}
<pre>
 
1 tochka
2 liniya
3 dyuim
4 vershok
5 piad
6 fut
7 arshin
8 sazhen
9 versta
10 milia
11 centimeter
12 meter
13 kilometer
 
Please choose a unit 1 to 13 : ? 13
 
Now enter a value in that unit : ? 1
 
The equivalent in the remaining units is :
 
tochka : 393700.8
liniya : 39370.08
dyuim : 3937.008
vershok : 2249.719
piad : 562.4297
fut : 328.084
arshin : 140.6074
sazhen : 46.86914
versta : 0.9373828
milia : 0.1339118
centimeter : 10000
meter : 100
 
Do another one y/n : ? n
</pre>
=={{header|Forth}}==
Tested with GForth.
Line 1,529 ⟶ 1,912:
Translation of python.
<syntaxhighlight lang="j">
#!/usr/bin/ijconsole
UNIT2MULT=: |:_2 (; ".)&;/\;:'arshin 0.7112 centimeter 0.01 diuym 0.0254 fut 0.3048 kilometer 1000.0 liniya 0.00254 meter 1.0 milia 7467.6 piad 0.1778 sazhen 2.1336 tochka 0.000254 vershok 0.04445 versta 1066.8'
 
Line 1,549 ⟶ 1,933:
NB. for use from os command line only:
exit echo conv }.ARGV</syntaxhighlight>
 
If this were named <code>ormol</code>
 
<pre>
$ /usr/local/j64-801/bin/jconsole j.ijsormol 8 meter
8 meter to:
┌──────────┬──────────┐
Line 1,650 ⟶ 2,036:
versta: 7,00000
milia: 1,00000</pre>
 
=={{header|jq}}==
{{works with|jq}}
<syntaxhighlight lang="jq">
def lpad($len): tostring | ($len - length) as $l | (" " * $l) + .;
 
def Units: {
"arshin" : 0.7112,
"centimeter": 0.01,
"diuym" : 0.0254,
"fut" : 0.3048,
"kilometer" : 1000.0,
"liniya" : 0.00254,
"meter" : 1.0,
"milia" : 7467.6,
"piad" : 0.1778,
"sazhen" : 2.1336,
"tochka" : 0.000254,
"vershok" : 0.04445,
"versta" : 1066.8
};
 
def cyrillic: {
"arshin" : "арши́н",
"centimeter": "сантиметр",
"diuym" : "дюйм",
"fut" : "фут",
"kilometer" : "километр",
"liniya" : "ли́ния",
"meter" : "метр",
"milia" : "ми́ля",
"piad" : "пядь",
"sazhen" : "саже́нь",
"tochka" : "то́чка",
"vershok" : "вершо́к",
"versta" : "верста́"
};
 
def request:
def explain: "number and unit of measurement expected vs \(.)" | error;
def check:
$ARGS.positional
| if length >= 2
then (try (.[0] | tonumber) catch false) as $n
| (.[1] | sub("s$";"")) as $u
| if $n and Units[$u] then [$n, $u]
else explain
end
else explain
end;
check ;
 
# Input: a number
# Delete unhelpful digits
def humanize($n):
tostring
| ( capture("^(?<head>[0-9]*)[.](?<zeros>0*)(?<tail>[0-9]*)$")
| (.head|length) as $hl
| if $hl > $n then .head + "."
elif .head | (. == "" or . == "0")
then .head + "." + .zeros + .tail[:1 + $n - $hl]
else .head + "." + (.zeros + .tail)[:1 + $n - $hl]
end ) // .;
 
def display:
Units
| . as $Units
| request as [$n, $unit]
| "\($n) \($unit)\(if $n == 1 then "" else "s" end) ::",
(to_entries[]
| "\(.key|lpad(10)) : \(($n * $Units[$unit] / .value) | humanize(5)) \(cyrillic[.key])"),
"" ;
 
display
</syntaxhighlight>
'''Invocation example'''
<pre>
jq -nr -f old-russian-measure-of-length.jq --args 2.3 meter
</pre>
{{output}}
<pre>
2.3 meters ::
arshin : 3.23397 арши́н
centimeter : 229.999 сантиметр
diuym : 90.5511 дюйм
fut : 7.54593 фут
kilometer : 0.0023 километр
liniya : 905.511 ли́ния
meter : 2.3 метр
milia : 0.00030799 ми́ля
piad : 12.9358 пядь
sazhen : 1.07799 саже́нь
tochka : 9055.11 то́чка
vershok : 51.7435 вершо́к
versta : 0.0021559 верста́
</pre>
 
=={{header|Julia}}==
Line 1,780 ⟶ 2,262:
 
Do another one y/n : n
</pre>
=={{header|M2000 Interpreter}}==
 
<syntaxhighlight lang="m2000 interpreter">
module OldRusianMeasureOfLength {
unit2mult=list:="arshin" := 0.7112, "centimeter" := 0.01, "diuym" := 0.0254, "fut" := 0.3048, "kilometer" := 1000.0, "liniya" := 0.00254, "meter" := 1.0, "milia" := 7467.6, "piad" := 0.1778, "sazhen" := 2.1336, "tochka":= 0.000254, "vershok" := 0.04445, "versta" := 1066.8
k=each(unit2mult)
menu // empty menu list
menu + "(exit)"
while k
menu + eval$(k!)
end while
double v
do
Print "Value, Unit";
input ":", v;
print " ";
menu !
if menu>0 then
print menu$(menu)
if menu$(menu)="(exit)" then exit
Print v;" ";menu$(menu);" to:"
v*=unit2mult(menu$(menu))
k=each(unit2mult)
while k
if eval$(k!)=menu$(menu) then continue
print format$("{0:-12}: {1}",eval$(k!), round(v/eval(k),9))
end while
else
exit
end if
always
}
OldRusianMeasureOfLength
</syntaxhighlight>
{{out}}
<pre>
Value, Unit: 1 meter
1 meter to:
arshin: 1.406074241
centimeter: 100
diuym: 39.37007874
fut: 3.280839895
kilometer: 0.001
liniya: 393.700787402
meter: 1
milia: 0.000133912
piad: 5.624296963
sazhen: 0.468691414
tochka: 3937.007874016
vershok: 22.497187852
versta: 0.000937383
</pre>
 
Line 2,811 ⟶ 3,345:
{{libheader|Wren-fmt}}
{{libheader|Wren-str}}
<syntaxhighlight lang="ecmascriptwren">import "io" for Stdin, Stdout
import "./fmt" for Fmt
import "./str" for Str
 
var units = [
Line 2,900 ⟶ 3,434:
centimeter : 10000.0
meter : 100.0
 
Do another one y/n : n
</pre>
 
=={{header|XPL0}}==
{{trans|Wren}}
<syntaxhighlight lang "XPL0">int Units, Unit, I, YN;
real Convs, Value;
 
[Units:= ["tochka", "liniya", "dyuim", "vershok", "piad", "fut",
"arshin", "sazhen", "versta", "milia",
"centimeter", "meter", "kilometer"];
 
Convs:= [0.0254, 0.254, 2.54, 4.445, 17.78, 30.48,
71.12, 213.36, 10668., 74676.,
1., 100., 10000.];
 
loop [for I:= 0 to 13-1 do
[if I+1 < 10 then ChOut(0, ^ ); IntOut(0, I+1);
ChOut(0, ^ ); Text(0, Units(I)); CrLf(0);
];
CrLf(0);
loop [Text(0, "Please choose a unit 1 to 13 : ");
OpenI(0);
Unit:= IntIn(0);
if Unit >= 1 and Unit <= 13 then quit;
];
Unit:= Unit-1;
loop [Text(0, "Now enter a value in that unit : ");
OpenI(0);
Value:= RlIn(0);
if Value >= 1. then quit;
];
Text(0, "^m^jThe equivalent in the remaining units is:^m^j^m^j");
Format(7, 8);
for I:= 0 to 13-1 do
[if I # Unit then
[RlOut(0, Value*Convs(Unit)/Convs(I));
Text(0, " : "); Text(0, Units(I)); CrLf(0);
];
];
CrLf(0);
YN:= ^ ;
while YN # ^y and YN # ^n do
[Text(0, "Do another one y/n : ");
OpenI(0);
YN:= ChIn(0) or $20;
];
if YN = ^n then quit;
CrLf(0);
];
]</syntaxhighlight>
{{out}}
<pre>
1 tochka
2 liniya
3 dyuim
4 vershok
5 piad
6 fut
7 arshin
8 sazhen
9 versta
10 milia
11 centimeter
12 meter
13 kilometer
 
Please choose a unit 1 to 13 : 13
Now enter a value in that unit : 1
 
The equivalent in the remaining units is:
 
393700.78740157 : tochka
39370.07874016 : liniya
3937.00787402 : dyuim
2249.71878515 : vershok
562.42969629 : piad
328.08398950 : fut
140.60742407 : arshin
46.86914136 : sazhen
0.93738283 : versta
0.13391183 : milia
10000.00000000 : centimeter
100.00000000 : meter
 
Do another one y/n : n
Anonymous user