Question

square the elements of a linear list of numbers (square ‘(1 -3 -5 7)) => (1...

square the elements of a linear list of numbers
(square ‘(1 -3 -5 7)) => (1 9 25 49)
using DrRacket
The code has to be from scratch, no library functions. and kindly explain what each line of code is doing.

Homework Answers

Answer #1

Here is the required code in DrRacket:

;defining a list that contains elements
(define l (list 1 -3 -5 7))

;displaying given elements
(display "Elements Given: \n")
(for ([i l])
(display i)
(display " "))

;displaying squared elements
(display "\n\nSquared Elemnts: \n")
(for ([i l])
(define x (* i i)) ;defining variable x that stores the square of ith element in list
(display x)
(display " "))

Here is the Output of the Sample List:

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
Write a program using DrRacket: is a member of a list. (Can you explain everything) code...
Write a program using DrRacket: is a member of a list. (Can you explain everything) code must be designed from the scratches no library functions (member 1 '(2 3 4 1 5)) => true (member 1 '(2 3 4 (1) 5)) => false
LANGUAGE: SCHEME R5RS Create a procedure called preceeding that will take a list of numbers as...
LANGUAGE: SCHEME R5RS Create a procedure called preceeding that will take a list of numbers as argument and determine the elements and indices of those elements that preceed a negative number in the given list. The returned information should be in the form of a pair of lists: ((values) . (indices)). E.g. (preceeding '(1 -2 3 4 -5 6 -7 -8)) → ((1 4 6 -7).(0 3 5 6)) ;note: drracket will display this as ((1 4 6 -7) 0...
Consider the following sequence of numbers 8, 1, 11, 4, 2, 9, 10, 5, 3, 12,...
Consider the following sequence of numbers 8, 1, 11, 4, 2, 9, 10, 5, 3, 12, 6, 7 c) Sort the list using quick sort with the middle element as pivot. Show the state of the list after each call to the partition procedure. You are not required to write code for this question. You need to trace through the different sorting algorithms using the given list. Please could I get an answer to the above question through using 9...
# Python Given the list values = [], write code that fills the list with each...
# Python Given the list values = [], write code that fills the list with each set of numbers below. Note: use loops if it is necessary 1 2 3 4 5 6 7 8 9 10 0 2 4 6 8 10 12 14 16 18 20 1 4 9 16 25 36 49 64 81 100 0 0 0 0 0 0 0 0 0 0 1 4 9 16 9 7 4 9 11 0 1 0...
Consider the matrix list x = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. Write...
Consider the matrix list x = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. Write a list comprehension to extract the first column of the matrix [1, 4, 7]. Write another list comprehension to create a vector of twice the square of the middle column.
Java please. Given a sequence of unsorted numbers, determine how badly out of order they are....
Java please. Given a sequence of unsorted numbers, determine how badly out of order they are. Write a program that, for any given sequence of unique natural numbers, will compute the 'distance' between that original ordering and the same set of numbers sorted in ascending order. The distance should be computed by calculating how far displaced each number is in the original ordering from its correct location in the sorted list and summing those results. For instance, given the list...
1) Compute 3^23 mod 5 by using modular arithmetic. List the steps. 2) S4 is a...
1) Compute 3^23 mod 5 by using modular arithmetic. List the steps. 2) S4 is a group of all permutations of 4 distinct symbols. List all the elements of S4. Is S4 an abelian group? Use an example to explain. 3) φ(25) refers to the positive integers less than 25 and relatively prime to 25. List these integers.
Suppose we have the following 25 residuals, 8, ?5, 7, 1, ?3, ?3, 3, ?5, 1,...
Suppose we have the following 25 residuals, 8, ?5, 7, 1, ?3, ?3, 3, ?5, 1, 9, 8, ?5, 7, 1, ?3, ?3, 3, ?5, 1, 9, 8, ?5, 7, 1, ?3 from the linear model: y = ?0 + ?1x1 + ?2x2 + . (a) Please use Durbin-Watson statistic to test H0 : ? = 0 at 5% level of significance. (b) Please use run test to examine if there are too many runs at 5% level of significance.
1. Find the derivatives of each of the following functions: (a) ?(?)=5?3−7?2−9?+√5 (b) ?(?)=3?-4+6√? (c) ?(?)=6/?4−7/?3+3/?+1
1. Find the derivatives of each of the following functions: (a) ?(?)=5?3−7?2−9?+√5 (b) ?(?)=3?-4+6√? (c) ?(?)=6/?4−7/?3+3/?+1
Write a code in c++ using linear insertion following the steps below. Comment your work. 1....
Write a code in c++ using linear insertion following the steps below. Comment your work. 1.    Ask the user for the name of a file containing data. If it does not exist, the program should display an error, then ask for a new file name. Entering an asterisk (*) as the first and only character on a line should terminate the program. 2.     You can use a statically-allocated one-dimensional array of doubles for this with length 100. You...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT