Take three positive integers and return an integer

Assignment Help Computer Engineering
Reference no: EM132213357

-Write scheme functions for the following making sure they run on Dr Racket "Advanced Student".

-Built-in functions in Dr Racket, with the exception of modulo and quotient, can not be used.

-Do not use other languages such as Java, C, etc..

1) combine3 takes three positive integers and return an integer which is made of the last two digits of the first integer, the first and last digits of the second integer and the first two digits of the last integer. If any of the integers has less than two digits return 0. For example:

( combine 4 124 80534 ) will return 0

( combine3 247939 968634 40348726 ) will return the integer 399440 and

( combine3 5678 456 9264 ) will return 784692.

If any of your numbers has less than two digits, return 0.

Note that you probably need to define several auxiliary functions.

2) inc-by-n takes an integer x and a digit d and returns an integer where each digit in x has been incremented by n. If the result of the incrementation would exceed 9, the result mod 10 will be used. For example:

(inc-by-n 53462 3) will return 86795 and

(inc-by-n 682901 4) will return 026345

Note that if the first digit of the answer is "0" it will not print.

3) countnumber takes a list of integers L (with possible nested sublists) and an integer n and count the number of instances of n in the list. For example:

( countnumber ‘( 5 7 34 28 5 72 ( 5 ) ) 5) returns 3 and

( countnumber ‘( 3 ( 67 34 ( 29 56) 23 ) 56 ( 5 ( 45 34 56 ) 0 ) ) 34 ) returns 2

4) mapeven takes a function and a list and return a list similar to the list argument where the function has been applied to every other element starting with the second one. For example:

( mapevensquare ‘( 3 6 22 9 5 7 10 15 ) ) will return ( 3 36 22 81 5 49 10 225 )

( mapeven even? ‘( 3 6 22 9 5 7 10 15 ) ) will return ( 3 #t 22 #f 5 #f 10 #f )

( mapeven list? ‘( 2 ( 3 4 ) 6 10 ( 88 23 ) ( 5 ) )) will return ( 2 #t 6 #f ( 88 23 ) #t)

Note that the function applied only to the top elements of the list. Make sure that your function works with any relevant function, and that it works with lists of even and odd length.

5) addTheSquares takes a list of integer and returns the sum of all the squares. For example:

( addTheSquares ‘( 6 3 9 2 6 )) will return 166 ( i.e. 36 + 9 + 81 + 4 + 36 )

6) Write a tail recursive version of #5 makeInsertInList takes an argument x and returns a function which will have a list argument and will insert x after each element of the list.

Reference no: EM132213357

Questions Cloud

Compute the taxable gain or loss : A tax payer acquires an asset through manufacturing it and he incurred the following costs: direct material SR 100,000, direct labor SR 50,000 and manufacturing
Allow a user to enter a numeric grade and then determine : Write a script that allows a user to enter a numeric grade and then determine the letter grade.
Write a select statement that returns these column names : Write a SELECT statement that returns these column names and data from the Invoices table.
Which activities are different across the two establishments : Make a list of activities to process an order that consists of a main course (sandwich, pizza, burger, etc.), a drink and a side order (3 items on the menu).
Take three positive integers and return an integer : Combine3 takes three positive integers and return an integer which is made of the last two digits of the first integer.
Create a row vector c that is an integer data type : Create a row vector C that is an integer data type with elements counting backward in increments of 5 from 200 to 0.
What state and federal enforcement agencies have played role : What state and federal enforcement agencies have played a role in the investigation of white collar crime? Name a few with some recent examples.
Read four numbers and find the sum of these numbers : If the sum is in the range 50 to 99 display the message that the sum is in the range of 50 to 99 and also display the first two numbers only.
What amount of interest should turnbull include : Turnbull Corporation is constructing an office building that it will use in its business. Construction of the building started in the current accounting period.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd