How to resolve the algorithm Old Russian measure of length step by step in the Racket programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Old Russian measure of length step by step in the Racket programming language
Table of Contents
Problem Statement
Write a program to perform a conversion of the old Russian measures of length to the metric system (and vice versa).
It is an example of a linear transformation of several variables.
The program should accept a single value in a selected unit of measurement, and convert and return it to the other units: vershoks, arshins, sazhens, versts, meters, centimeters and kilometers.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Old Russian measure of length step by step in the Racket programming language
Source code in the racket programming language
#lang racket
(define units
'([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]))
(define (show u)
(printf "1 ~s to:\n" u)
(define n (cadr (assq u units)))
(for ([u2 units] #:unless (eq? u (car u2)))
(displayln (~a (~a (car u2) #:width 10 #:align 'right) ": "
(~r (/ n (cadr u2)) #:precision 4))))
(newline))
(show 'meter)
(show 'milia)
You may also check:How to resolve the algorithm Function definition step by step in the MAXScript programming language
You may also check:How to resolve the algorithm JSON step by step in the Hoon programming language
You may also check:How to resolve the algorithm Haversine formula step by step in the VBA programming language
You may also check:How to resolve the algorithm Count in octal step by step in the Picat programming language
You may also check:How to resolve the algorithm Euler method step by step in the ATS programming language