Lisp program
count-of (symbol list): Write a function named count-of that takes two parameters, a symbol and a list. Count the number of instances of x in the list. Do not count the number of x in any sub-lists within the list.
Test: count-of 'a '(a 'a(a c) d c a).
Result: 2
trim-to (symbol list): Write a function named trim-to that takes a symbol and list as parameters. Return a new list starting from the first occurrence of the input symbol in the input list. If there is no occurrence of the symbol, return nil.
Test: trim-to 'c '(a b c d e)
Result: (C D E)
(defun count-of (symbol l)
(if (null l)
0
(if (equal (car l) symbol)
(+ 1 (count-of symbol (cdr l)))
(count-of symbol (cdr l))
)
)
)
(defun trim-of(symbol l)
(if (null l)
l
(if (equal (car l) symbol)
l
(trim-of symbol (cdr l))
)
)
)
Lisp program count-of (symbol list): Write a function named count-of that takes two parameters, a symbol...
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))
5. Define a LISP function MONTH-INTEGER which takes as argument a symbol that should be the name of a month, and which returns the number of the month. For example, (MONTH-INTEGER MARCH) 3 and (MONTH-INTEGER JUNE) 6. If the argument is not a symbol that is the name of a month, the function should return the symbol ERROR. E.g., (MONTH-INTEGER C) ERROR, (MONTH-INTEGER 7) ERROR ( MONTH-INTEGER 'QUOTE)-> ERROR, and ( MONTH-INTEGER "(MAY))-> ERROR. 6. Define a LISP function SCORE->GRADE...
Write a function named insertBeforeKey that takes the parameters as follows list as an char array, capacity for the capacity of the array, numItems has the number of items in the array, key is an element of the array before which newVal is to inserted. Assume key is always present in the array. and newVal has the new value to be inserted into the array. If the array is at capacity then the function should return -1, otherwise return 0...
Write in LISP, Write a function named ackermann that takes two integers. Use the following function definition: (Note: due to this function’s complexity it may not finish for inputs larger than 3) ?(?,?) = { ? + 1 ?? ? = 0 ?(? − 1,1) ?? ? = 0 ?(? − 1,?(?,? − 1)) ??ℎ?????? Sample: (print (ackermann 1 1))) Sample output: 3
Write a LISP function HASSUBS which receives a list “s” and checks for sublists. If it has sublist return T, else return a NIL
help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and an int parameter. If both string parameters represent binary numbers and the int parameter is equal to a positive number less than or equal to the length of the longest string parameter, the function should return a binary string whose length is equal to two times the length of the maximum length of the two string parameters whose value is equal to the sum...
1. Write a Lisp function called piece which takes a single argument x and implements the following piecewise linear function: piece(x) = x if 0 < x < 1 2. Write a Lisp function called intList which takes two integer arguments, a and b and returns the list of all integers from a to b (inclusive at both ends). For example, (intList 3 8) should return (345678) 1. Write a Lisp function called piece which takes a single argument x...
2. Write a LISP function COUNTLETS which takes a list and returns the number of top-level alphabetic atoms in the list. For example: COUNTLETS ( (A 2) B 3 C4 (D 5))) Returns the value 2, the letters A and D are not at the top level
(C++) Write a function, remove, that takes three parameters: an array of integers, the number of elements in the array, and an integer (say, removeItem). The function should find and delete the first occurrence of removeItem in the array. (Note that after deleting the element, the number of elements in the array is reduced by 1.) Assume that the array is unsorted. Also, write a program to test the function. Your program should prompt the user to enter 10 digits...
Write a function named "write_string" that takes no parameters and doesn't return a value. This function will write the string "hockey" to a file named "sacrifice.txt". If a named "sacrifice.txt" already exists it should be overwritten. (Python) Can you help me?