Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Phone numbers are usually administrated at a national level. An area code of a phone number can be used to determine if a 10-digit Canadian

Phone numbers are usually administrated at a national level. An area code of a phone number can be used to determine if a 10-digit Canadian phone number is local or within a specific region, as shown below. The first three digits of a phone number are considered an area code. Currently, the area code in Greater Toronto Area (GTA) is 416, 437, or 647. Write a function gta-number? that consumes a phone number and produces a Boolean value (true if the number is in GTA and false otherwise). You can assume the phone number given is a valid 10-digit number, so you do not need to check the format, such as length and sign.

For example:

(gta-number? 4163922489) true > (gta-number? 5198884567) false > (gta-number? 4163975981) true > (gta-number? 6471234567) true > (gta-number? 4371234567) true

Current code I have now is:

(define (gta-number? num) (cond [(string=? (substring num 0 3) "416") #t] [(string=? (substring num 0 3) "437") #t] [(string=? (substring num 0 3) "647") #t] [else #f]))

(gta-number 6478099825)

It says:

substring: expects a string, given 6478099825

don't know why, can you please help me fix it?

Please run it on your computer, if the syntax is ok then post the answer to me thanks a lot!

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions