In Scheme language
Create a second function "vecfn" that allows one to pass the function to perform on the input lists as the first argument. Below are the test cases that should work when you type them in.
(display (vecfn - '(1 2 3) '(4 5 6))) (newline) (display (vecfn + '(4) (list (sqrt -1)))) (newline) (display (vecfn / '(1 2 3) '(1 4 5))) (newline)
Finally, add a "vecfun" to the syntax of Scheme. Submit a single text file.
List values are given as input,
If two list's are of same length then the List values are added
correspondingly.
If they are of different length then the length of list with lesser
length is made equal with the list with greater length. Then the
values are added correspondingly.
Function - append-zeroes is used to append extra zero's to get make the length equal.
Code for Adding to List .
(define (append-zeroes lst n)
(append lst (make-list (abs n) 0)))
(define (vecadd lst1 lst2)
(let ((diff (- (length lst1) (length lst2))))
(cond [(< diff 0)
(map + (append-zeroes lst1 diff) lst2)]
[(> diff 0)
(map + lst1 (append-zeroes lst2 diff))]
[else (map + lst1 lst2)])))
In Scheme language Create a second function "vecfn" that allows one to pass the function to...
USING SCHEME PROGRAMMING LANGUAGE define a function addSubList that processes a list of lists of numbers and adds up all sub-lists. The output of your function is a flat list of numbers. (You can assume that your function only receives valid input). Example: (define Q '(1 2 (3 4) 1 5 (7 8))) ;;;;;;;;;;;;;;;;;;;;; ; (addSubList Q) ; => '(1 2 7 1 5 15) ;;;;;;;;;;;;;;;;;;;
Please try to write the code with Project 1,2 and 3 in
mind. And use java language, thank you very much.
Create an Edit Menu in your GUI
Add a second menu to the GUI called Edit which will have one
menu item called Search. Clicking on search should prompt the user
using a JOptionPane input dialog to enter a car make. The GUI
should then display only cars of that make. You will need to write
a second menu...
how would i create the function apply in scheme?
A my-apply function that does the same thing as it
Higher-order Functions A function is called a higher-order function (also called a functional form) if it takes a function as an argument or returns a newly constructed function as a result Scheme has several built-in higher-order functions, for example apply takes a function and a list and applies the function with the elements of the list as arguments input (apply (3...
Scheme Language: Define a function nondecreastream, which takes in a stream of numbers and outputs a stream of lists, which overall has the same numbers in the same order, but grouped into segments that are non-decreasing. For example, if the input is a stream containing elements 1 2 3 4 1 2 3 4 1 1 1 2 1 1 0 4 3 2 1 ... the output should contain elements (1 2 3 4) (1 2 3 4) (1...
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...
Write a program in scheme using eopl language. Define a function "symbol-count" which takes a flat list of symbols and returns a list of lists in which each symbol is paired with the count of how many times it occurs in the original input. > (symbol-count '(b a)) '((b 1) (a 1))
plz
in Scheme
b. [2 marks] Create a function (alternate listi list2) that creates a list by alternating elements from the two given input lists. E.g.: (alternate '(0 000) '(1 1 1 1 1 1)) + (010101 c. [2 marks] Create a procedure (count x L) that returns the number of instances of the value x in the list L. E.g.: (count 3 '(1 4 3 6 2 3 3 1 4 3 5 7)) + 4 (count 'b'(4 b...
** Language Used : Python ** PART 2 : Create a list of unique words This part of the project involves creating a function that will manage a List of unique strings. The function is passed a string and a list as arguments. It passes a list back. The function to add a word to a List if word does not exist in the List. If the word does exist in the List, the function does nothing. Create a test...
C Programming Language on Linux - Word Frequency Program Please write a Program in C that will accept a text file name as a command-line argument via a main program that will do the following: First, read the file (first pass) and create a linked list of words (in their order of occurrence), with the frequency of each word set to 0. Then, read the file (second pass) and for each word identified, search the linked list, and when found,...
NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...