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
Determine the translation
dem82 [27]
The answer is 3 units down and one unit left.
8 0
3 years ago
Read 2 more answers
Write the equation of the line that passes through the point (0,16) with a slope of 4/5 or 4 over 5
ololo11 [35]
Y= 4/5x+16
using the format y=mx+b
5 0
3 years ago
According to the sequence of numbers, find the exponential function.
Vikki [24]
The answer to this is 3
4 0
3 years ago
-.At a fair hamburgers sell for $3.00 each and hot dogs sell for $1.50 each. The equation 3x + 1.5y = 30 describes the number of
NikAS [45]

Answer:

Part a) The y-intercept is the point (0,20) and the x-intercept is the point (10,0)

The graph in the attached figure

Part b) See the procedure

Step-by-step explanation:

<u><em>The questions are</em></u>

Part a) Find the intercepts and graph the function

Part b) What does each intercept represent?

Part a) Find the intercepts and graph the function

Let

x-----> the number of hamburgers

y ----> the number of hot dogs

we have

3x+1.5y=30

Remember that

The <u><em>y-intercept</em></u> is the value of y when the value of x is equal to zero

so

For x=0

3(0)+1.5y=30

1.5y=30

y=20\ hot\ dogs

The y-intercept is the point (0,20)

The <u><em>x-intercept</em></u> is the value of x when the value of y is equal to zero

so

For y=0

3x+1.5(0)=30

3x=30

x=10\ hamburgers

The x-intercept is the point (10,0)

Plot the intercepts and graph the line

see the attached figure

Part b) What does each intercept represent?

The x-intercept is the number of hamburgers they can buy if they buy no hot dogs

The y-intercept is the number of hot dogs they can buy if they buy no hamburgers      

5 0
3 years ago
What is the value of 2|6+p|-3p^3 when p = -2 ?<br><br> -32<br> -16<br> 32<br> 56
Allushta [10]
Here, you have to plug in -2 for p. I’m doing that you get that the answer will be 32.

4 0
4 years ago
Read 2 more answers
Other questions:
  • 25 divided by 405 with working
    11·1 answer
  • A line segment is drawn from (3, 2) to (3, 9) on a coordinate grid.
    5·2 answers
  • Number 7 I need help
    10·1 answer
  • In the diagram below, DAB and DAC are adjacent angles. If mDAC = 25°, what is mDAB in degrees? What is mBAC in degrees?
    12·2 answers
  • What are the x-intercept and y-intercept of the graph of y=13x−6 ?
    7·1 answer
  • Please help would mean a lot :?)
    7·2 answers
  • There are 12 inches for every 1 foot. How many inches are equivalent to 4 feet?
    5·1 answer
  • In a contest each finalist must answer 5 questions correctly .Each question is worth twice as much as the question before it. Th
    9·1 answer
  • Please help me!! How do I do this?
    9·2 answers
  • A sailboat travels at an average speed of 8 km/h. How many kilometers are traveled in 20 h at that speed?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!