Jump to content

Old Russian measure of length: Difference between revisions

Frink
(Added solution for Action!)
(Frink)
Line 1,184:
 
 
</pre>
 
=={{header|Frink}}==
One of Frink's unique features is tracking units of measure through all calculations. It is easy to add new units of measure and allow them to be automatically converted between any existing units. Frink's standard data file contains 642 units of length (not including prefixes) that this program can convert between.
<lang frink>arshin := (2 + 1/3) ft
vershok := 1/16 arshin
sazhen := 3 arshin
verst := 1500 arshin
versta := verst
 
do
{
valstr = input["Enter unit of measure: ", "1 arshin"]
val = eval[valstr]
if ! (val conforms length)
println["$valstr is not a unit of length."]
} until val conforms length
 
println["$valstr = "]
println[" " + (val -> "arshin")]
println[" " + (val -> "vershok")]
println[" " + (val -> "sazhen")]
println[" " + (val -> "verst")]
println[" " + (val -> "feet")]
println[" " + (val -> "meters")]
println[" " + (val -> "centimeters")]
println[" " + (val -> "kilometers")]</lang>
{{out}}
<pre>
Enter unit of measure: [1 arshin]
1 arshin =
1 arshin
16 vershok
1/3 (approx. 0.33333333333333333) sazhen
1/1500 (approx. 0.00066666666666666667) verst
7/3 (approx. 2.3333333333333333) feet
889/1250 (exactly 0.7112) meters
1778/25 (exactly 71.12) centimeters
889/1250000 (exactly 0.0007112) kilometers
</pre>
 
494

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.