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
lions [1.4K]
3 years ago
11

Define a recursive function prefix that accepts a positive integer n and a list xs as input, and returns a list containing only

the first n elements in xs. - This function must have a recursive definition and does not use any library functions!

Mathematics
1 answer:
Sauron [17]3 years ago
6 0

Answer:

F# Code:

let rec prefix n list =

//Extracting head and tail elements

let valHead = (Listhead list)

let valTail = (Listtail list)

// Checking n value

match n with

| 0 -> []

| _ -> [valHead] at (prefix (n-1) valTail) // Creating list recursively

//Testing function

let lstT = [1; 2; 3; 4; 5]

printfn "%A" (prefix 3 lstT)

printfn "%A" (prefix 2 lstT)

printfn "%A" (prefix 4 lstT)

Step-by-step explanation: see attachment below for sample run

You might be interested in
Solve this fast please… and thank you so much :)
natita [175]

Answer:

hi

Step-by-step explanation:

7 0
3 years ago
Read 2 more answers
coach brings 3 quarts of drink to practice. He gives the same amount to 16 players. how many ounces does each player get?
Elena L [17]
16dividedby3 which is 5 and 1 third or 5 remainder 1
4 0
3 years ago
Two opposite integer are 12 unit apart on a number line .what are the integers?​
fomenos

Answer:

6 and -6

Step-by-step explanation:

Since they're 12 units apart that means one of them is 6 and the fact they're opposites means the other is -12

7 0
3 years ago
I need to find the equation for this.. I keep getting confused please explain
weqwewe [10]
The vertex form equation is y = a(x-h)^2+k
Lets substitute our given information.

y = a(x-1)^2+5

Now, lets put in the coordinate it needs to pass through.

8 = a(2-1)^2 + 5
8 = a + 5
a = 3

Now, lets make the equation now that we know a.

y = 3(x-1)^2+5

Hope this helps!
6 0
3 years ago
At a dog park,there are12 golden retrievers and 20 poodles.what are the ratio of retrievers to poodles?
WITCHER [35]

Answer:

12:20

Step-by-step explanation:

3 0
3 years ago
Other questions:
  • If G is the midpoint of FH, FG= 14x + 25 and GH = 73- 2x, find FH
    10·1 answer
  • If h left-parenthesis x right-parenthesis equals f left-parenthesis x right-parenthesis times g left-parenthesis x right-parenth
    7·1 answer
  • Solve for x squared - 12x+59=0
    11·1 answer
  • Root 3 cosec140° - sec140°=4<br>prove that<br><br>​
    14·1 answer
  • Sheldon needs to buy 8 gallons of ice cream, $2.50 for 1 pint and $4.50 for 1 quart. which is the better deal
    14·1 answer
  • The school band is having a car wash to raise money to purchase new uniforms if they charge $4 per car,how many cars must band m
    15·2 answers
  • Match each fraction with its percent equivalent.
    11·2 answers
  • The probability that a customer's order is not shipped on time is 0.04. A particular customer places three orders, and the order
    5·1 answer
  • 22. A figure is shown.
    7·1 answer
  • Anybody can help me?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!