1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Varvara68 [4.7K]
3 years ago
7

Define a romanNumberToInt function that converts a RomanNumber value, which is a list of Roman digits, into an integer. Hints: -

Assume the Roman number representation is valid. - Use recursion to sum up number in romanNumber because it is a list. - Use pattern guards to manage case when digits come in reverse order, e.g. IX, IV.
Computers and Technology
1 answer:
USPshnik [31]3 years ago
6 0

Answer:

Check the explanation

Explanation:

type RomanDigit = int

type RomanNumeral = RomanDigit list

type RomanDigit = I | V | X | L | C | D | M

type RomanNumeral = RomanNumeral of RomanDigit list

/// Converting a single RomanDigits to an integers here

let digitToInt =

function

| I -> 1

| V -> 5

| X -> 10

| L -> 50

| C -> 100

| D -> 500

| M -> 1000

// testing here

I |> digitToInt

V |> digitToInt

M |> digitToInt

let rec digitsToInt = function

 

// empty is notified by using 0

| [] -> 0

// special case when a smaller comes before larger

// convert both digits and add the difference to the sum

// Example: "IV" and "CM"

| smaller::larger::ns when smaller < larger -> (digitToInt larger - digitToInt smaller) + digitsToInt ns

// otherwise convert the digit and add to the sum

| digit::ns -> digitToInt digit + digitsToInt ns

// tests

[I;I;I;I] |> digitsToInt

[I;V] |> digitsToInt

[V;I] |> digitsToInt

[I;X] |> digitsToInt

[M;C;M;L;X;X;I;X] |> digitsToInt // that is 1979

[M;C;M;X;L;I;V] |> digitsToInt // that is 1944

/// converts a RomanNumeral to an integer

let toInt (RomanNumeral digits) = digitsToInt digits

// test

let x = RomanNumeral [I;I;I;I]

x |> toInt

let x = RomanNumeral [M;C;M;L;X;X;I;X]

x |> toInt

You might be interested in
______ is the software that blocks a user from being able to access your computer.
antiseptic1488 [7]
The answer is firewall. It is a network security device that observes inbound and outbound network traffic and chooses whether to allow or block specific traffic based on a well-defined set of security rules. Firewalls have been a first line of protection in network security for over 25 years. The firewall present a barrier between measured and secured internal networks that can be trusted and untrusted outside networks, for example the Internet. A firewall can be software, hardware, or even both.
8 0
3 years ago
An educational institution has a number of buildings in the campus. Each building has its own independent network system, and al
Aloiza [94]
Answer: star topology.

Explanation:

The layout of the way how the computers in a netword are interconnected is called network tipology.

Some types of network topologies are:

1) Point-to-point tipology: all the computers are connected to each other directly (computer-to-computer, in pairs, this is a direct link between each two computers).

2) Bus topology: all the nodes (computers or server) are connectect to a maing cable.

3) Star topology: all the computers are connected to a central computer or server which is called central hub. This is the layout described in the question.

4) Ring topology: the computers are connectec in a circular path; each computer is connected to the next computer.

5) Mesh: every computer is connected to every other computer.




8 0
2 years ago
Read 2 more answers
Harry is creating a PowerPoint presentation and wants all the slides to have a uniform look.
Ne4ueva [31]

Answer:

✔ Slide Master view

✔ layout and theme

✔ PowerPoint template

Explanation:

On Edg

4 0
3 years ago
Given the following method static void nPrint(String message, int n) { while (n &gt; 0) { System.out.print(message); n--; } } Wh
Zolol [24]

Answer: aaaa

Explanation:

Since the condition of n > 0 is satisfied, the number will decreement and the print out will look like the above answer.

3 0
3 years ago
Which of the following is a quality of a mixed economy?
tekilochka [14]

Answer:

Image result for Which of the following is a quality of a mixed economy? 1. Businesses have complete control of what they import. 2. Individuals have complete control of what they export. 3.Leaders determine the wages of individuals without any input from businesses. 4. Government encourages free trade of specific products.

'One main characteristic of a mixed economy is the ownership of goods by both private and government/state-owned entities. Monopolies have the potential to occur in this type of economy, but the government closely monitors this. For the economy to be mixed, the government can control some parts but not all.

Explanation:

6 0
3 years ago
Other questions:
  • You will write a program that reads a binary file that contains records of creatures. Each record can be stored in a Creature st
    10·1 answer
  • In general terms, a program that is broken into smaller units of code such as methods, is known as a ________
    6·1 answer
  • ​User documentation _____. Group of answer choices ​allows users to prepare overall documentation, such as process descriptions
    9·1 answer
  • Digital certificates can be used for each of these EXCEPT _____. A. to encrypt channels to provide secure communication between
    13·1 answer
  • The information stored in the _____ is used by the DBMS for a recovery requirement triggered by a ROLLBACK statement, a program'
    7·1 answer
  • What was your learning target for today
    9·2 answers
  • Which among the following choices is correct based on the two statements listed below? Statement 1: When the lexical analyzer sc
    12·1 answer
  • What is the output of the following code:
    12·1 answer
  • What legal protection would cover a person invention?
    10·2 answers
  • Hey everyone please let my friends answer please?????? .
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!