Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Scheme, Create a simple function divisible-by? which takes two numbers and returns #t or #f if the first parameter is divisible by the second

In Scheme, Create a simple function divisible-by? which takes two numbers and returns #t or #f if the first parameter is divisible by the second parameter. Note: if the first parameter and second parameter are the same number, it should consider this a #f case.

For example:

(divisible-by? 10 2) #t

(divisible-by? 10 3) #f

(divisible-by? 2 2) #f

Then

Remember: Currying is when we use a function to build a function that we can use. Create a Curry Function called not-divisible-by. not-divisible-by should take a number as a parameter and use that to create and return a function that takes a parameter that uses divisible-by? This should create the ability to pass in the number you want to check if another number is not divisible by:

Example

((not-divisible-by 2) 10) #f

((not-divisible-by 3) 10) #t

(not-divisible-by 4) #

Note: Example of currying:

(define add-two (lambda (a b) (+ a b)))

(define add-this-to (lambda (val)

(lambda (num) (add-two val num))))

((add-this-to 5) 6) 11

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions

Question

=+a) Are these column, row, or total percentages? How do you know?

Answered: 1 week ago

Question

Why is the optimal cache replacement policy important?

Answered: 1 week ago