Question

SCHEME [2 marks] Define a procedure between? that takes 3 numbers representing a value (x) and...

SCHEME

  1. [2 marks] Define a procedure between? that takes 3 numbers representing a value (x) and a range (a,b) respectively . The procedure should return true if the first argument falls between the remaining two (inclusive), that is if x ∈ [a,b].
    Note: the two arguments representing the range can be in either order ([a,b] or [b,a]).
    E.g. (between? 1 2 3) → #f
    E.g. (between? 7.5 5 10) → #t
    E.g. (between? 7 10 5) → #t

Homework Answers

Answer #1

Code:

(define (between? x a b)
(cond ((or (and (> x a) (< x b)) (and (> x b)(< x a))) #t) ;;if value is betwwen a and b OR b and a return true
(else #f))) ;;else return false

Snapshot of Code and Output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
LISP [3 marks] Write a procedure called triangle that takes three numbers as arguments representing the...
LISP [3 marks] Write a procedure called triangle that takes three numbers as arguments representing the three side-lengths of a triangle. The procedure should classify the triangle and return one of the following strings: "Equilateral" "Isoceles" "Scalene". E.g. (triangle 2 3 4) → "Scalene" E.g. (triangle 2 3 2) → "Isoceles"
Defining a Class Define the class Rectangle. It’s constructor takes a pair of numbers representing the...
Defining a Class Define the class Rectangle. It’s constructor takes a pair of numbers representing the top-left corner, and two other numbers representing the width and height. It has the following methods: get_bottom_right() - return the bottom right corner as a pair of numbers. move(p) - move the rectangle so that p becomes the top-left corner (leaving the width and height unchanged). resize(width, height) - set the width and height of the rectangle to the supplied arguments (leaving the top-left...
a) Define a function to be x^3+3x-4 and define another function to be x^2-5x+10. **Note: Use...
a) Define a function to be x^3+3x-4 and define another function to be x^2-5x+10. **Note: Use different names for each function. b) Plot both functions from part a on the same graph from x=-5 to x=5. Define a range of 0 to 100 with the PlotRange option. Use the PlotLegends option to label the functions with their "Expressions". You may need to refer to the "Lab 3 Functions Continued" instructional notebook or the Documentation Center to see how options are...
JAVA Problem 1: Summing It Up Write a program, which takes two distinct integers separated by...
JAVA Problem 1: Summing It Up Write a program, which takes two distinct integers separated by space as input and prints the sum of all the integers between them, including the two given numbers. Note that the numbers can appear in either order. You may assume that both numbers are between –10, 000 and 10, 000. For example, if the input is as follows: 10 4 the output should be 49, since 10+9+8+7+6+5+4=49. Similarly, if the input is -3 10...
Solve: (5*2=10 marks) log3x+log3(x+2)=log38 2(-x + 3) = 18(2x+4) Divide 3x3 + 2x2 – 2 by...
Solve: (5*2=10 marks) log3x+log3(x+2)=log38 2(-x + 3) = 18(2x+4) Divide 3x3 + 2x2 – 2 by x – 3    Find the inverse function f-1(x) of the function    y = f(x) =    In a bacterial culture, the number of bacteria, f(t), is defined by the equation f(t) = Be0.02t where B is a constant, and t is the time elapsed in minutes If the number of bacteria at t= 5sec is 1000. find the number of bacteria in 30minutes.
1. Find the values of the following definite integrals: ?) ∫3−2(2x2 – 2) dx [5 Marks]...
1. Find the values of the following definite integrals: ?) ∫3−2(2x2 – 2) dx [5 Marks] ?) ∫9−1 4x1/5 dx [5 Marks] ? ∫20 (2x3 – 4x2 + 2) dx [5 Marks] Three data sets were collected by students during an experiment, the results of which are shown in the table 1 below: Table 1. Student Data from an experiment. Student 1 22.55 mL, 22.50 mL, 22.65 mL, 23.10 mL, 23.05 mL Student 2 24.25 mL, 24.30 mL, 24.55 mL,...
PYTHON 3 Write a program that prints the count of all prime numbers between A and...
PYTHON 3 Write a program that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows: A = 21212 B = A + 5000 Just a recap on prime numbers: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2, 5, 7, 11, 13, 17, 19, 23, and 29. Rules: You should first...
Write a public static method name productAll that takes in 2 arguments int a, int b,...
Write a public static method name productAll that takes in 2 arguments int a, int b, and returns the product of all values between those two numbers inclusive. Remember a can be less than b, b might be less than a, or they may be equal. They can also be positive or negative. Example: productAll(2, 5); int returned by method: 120 Example: productAll(5, 2); int returned by method: 120 Example: productAll(3, 3); int returned by method: 9 Example: productAll(3, 5);...
Write a public static method name productAll that takes in 2 arguments int a, int b,...
Write a public static method name productAll that takes in 2 arguments int a, int b, and returns the product of all values between those two numbers inclusive. Remember a can be less than b, b might be less than a, or they may be equal. They can also be positive or negative. Example: productAll(2, 5); int returned by method: 120 Example: productAll(5, 2); int returned by method: 120 Example: productAll(3, 3); int returned by method: 9 Example: productAll(3, 5);...
Intro to JAVA Problem 1: Summing It Up Write a program, which takes two distinct integers...
Intro to JAVA Problem 1: Summing It Up Write a program, which takes two distinct integers separated by space as input and prints the sum of all the integers between them, including the two given numbers. Note that the numbers can appear in either order. You may assume that both numbers are between –10, 000 and 10, 000. For example, if the input is as follows: 10 4 the output should be 49, since 10+9+8+7+6+5+4=49. Similarly, if the input is...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT