In racket language, define a procedure named build-naturals that returns the list (list 0 .. (- n 1)) for any natural number n. Example: (build-naturals 5) returns (0 1 2 3 4).. The procedure must call build-list. The procedure passed to build-list must be a lambda expression, not a named procedure
A function build-naturals is defined which accepts one parameter 'n'
CODE:
(define (build-naturals n)
(build-list n (lambda(x) (* x 1)))
)
(print (build-naturals 5))
SCREENSHOT:
OUTPUT:
***Please upvote if it helps and feel free to comment if you have
any query.
In racket language, define a procedure named build-naturals that returns the list (list 0 .. (-...
Overview The purpose of this assignment is to practice functional programming in the Racket Programming Language and to also reinforce the notion of the list as a universal data structure, by implementing various operations on binary search trees. Specification A binary search tree is a binary tree which satisfies the following invariant property: for any node X, every node in X's left subtree has a value smaller than that of X, and every node in X's right subtree has a...
Using Racket Create a Racket procedure compute_pos that reads numbers from the keyboard until 0 is read, count how many positive numbers are read, and also compute the sum of only positive numbers, and display the count and the sum of positive numbers in different lines. Note that 0 is not included in the computations. For example, if user enters: 3 6 -4 12 15 -9 -24 4 -3 -5 1 0 then your procedure should print positive count: 6...
In scheme coding language Write a function filterN that returns only the numbers n through m from a lat. For example: (filterN 4 6 (1 turkey 5 9 4 bacon 6 cheese)) returns (5 4 6). Use only functions add1, sub1, and, or, <, >, null?, number?, zero?, define, lambda, cond, and else in the code. Assume n < m
Language in Scheme e. (5 marks] Create a procedure (decreasing L) that returns a list of all of the consecutive decreasing subseqeuences in the input list. E.g., (decreasing (3 6 8 9 7 4 8 6 3)) + ((974) ( (decreasing '(7 6 5 4 8 5 2 5 1 5 2 1)) + (( 7 (decreasing '(1 2 3 4 5)) () 4) (8 6 3) (63)) 5 4)(654) (54)(8 5 2)(5 2) (5 1) (5 2 1) (2...
Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...
Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...
this is assembly language for x-86 processors using microsoft visual studio Create a procedure named FindThrees that returns 1 if an array has three consecutive values of 3 somewhere in the array. Otherwise, return 0. The procedure’s input parameter list contains a pointer to the array and the array’s size. Use the PROC directive with a parameter list when declaring the procedure. Preserve all registers (except EAX) that are modified by the procedure. Write a test program that calls FindThrees...
Language: Python Topic: Try/Except Function name : add_divide Parameters : list of ints, int Returns: float Description: Given a list of integers and a number, you want to add the numbers in the list to a total value by iterating through the given list. However, when the index you are at is divisible by the integer passed in, you must instead divide the current total by the element at that index. You must be careful when dividing the total (you...
Using Racket, write a bridgely? function that takes a list of at least 3 numbers and returns #true if it is bridgely, otherwise #false. A list of numbers is called "bridgely" if it contains at least 3 numbers, and every number in the list, except for the first and the last, is greater than both the first and the last number. Thus, these lists are bridgely: (list 1 2 3 4 5 6 5 4 3 2 1) (list 0...
Using scheme language, write the code for the following question 3 Define a procedure "Product" that takes two parameters and returns the product of them. Then, call you procedure using [5 points] > (Product 1040) 03d