Question

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
0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
2. Write a LISP function COUNTLETS which takes a list and returns the number of top-level...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Write a Lisp function called piece which takes a single argument x and implements the followin...

    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...

  • Write a function which takes a list and returns frequencies of each element in the list?...

    Write a function which takes a list and returns frequencies of each element in the list? For example: L=[‘a’,’b’,’a’,’c’,’d’,’b’]    Returns ‘a’: 2, ‘b’: 2, ‘c’: 1, ‘d’: 1

  • In Lisp 2. Code the function (replaceIn list possibleList repValue) which constructs a new list. It...

    In Lisp 2. Code the function (replaceIn list possibleList repValue) which constructs a new list. It examines list for occurrences of any of the atoms from the possibleList. Those are replaced with repValue. This only examines the top-level items in list. Example: > (replaceIn '(P A T T E R) '(T R) 'S) (P A S S E S) 3.   Code the function (insertAfter list atm insValue) which constructs a new list by inserting the specified insValue into the list...

  • Lisp program count-of (symbol list): Write a function named count-of that takes two parameters, a symbol...

    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...

  • In Lisp programming language a 16. (20 pts.) Write a function that takes a list of...

    In Lisp programming language a 16. (20 pts.) Write a function that takes a list of 0's and l's and "toggles" each element. Your function should include lambda expression that knows how to flip an individual element, plus an applicative operator to do this to every element of the list. Example: 1 0) List (0 0 1 1 0 1) should be transformed into (1 1 0 0

  • Lisp Scheme Write a procedure in Lisp Scheme called charflip that takes a string as a...

    Lisp Scheme Write a procedure in Lisp Scheme called charflip that takes a string as a parameter and returns a copy of this string, flipping the case of every character in an odd position (index 1, 3, 5, etc..). I suggest that you do this recursively. This means cons, car and cdr will come in handy, as will these functions: • char-upper-case? • char-downcase • char-upcase • list->string • string->list Here’s this function in action. scheme@(guile-user)> (charflip "hatburg") $16 =...

  • Write the function deep_contains. It takes as input a number and a list. That list might...

    Write the function deep_contains. It takes as input a number and a list. That list might contain lists as elements, and those lists might contain lists, etc. The deep_contains' function should return a Boolean indicating whether the number is contained inputted list, or a sublist of it, or a sublist of that, and so forth. For example: deep_contains (3, (1,3,5]) returns True deep_contains(3, 11, [3,5]]) returns True deep_contains (3, 1, [[3,4],5),6]) returns True deep_contains (2, (1,3,5]) returns False This function...

  • 5. Define a LISP function MONTH-INTEGER which takes as argument a symbol that should be the...

    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 the function below in scheme/lisp programming language. Drracket Exercise: It is well known that n^2...

    Write the function below in scheme/lisp programming language. Drracket Exercise: It is well known that n^2 is equal to the sum of the first n odd numbers. For example, 16 = 4^2 = 7 + 5 + 3 + 1. Write a function that takes as input a natural number, n, and that returns the square of its input by adding the first n odd numbers. Your code may not contain delayed operations and must use accumulative recursion.

  • Write a function called most_consonants(words) that takes a list of strings called words and returns the...

    Write a function called most_consonants(words) that takes a list of strings called words and returns the string in the list with the most consonants (i.e., the most letters that are not vowels). You may assume that the strings only contain lowercase letters. For example: >>> most_consonants(['python', 'is', 'such', 'fun']) result: 'python' >>> most_consonants(['oooooooh', 'i', 'see', 'now']) result: 'now' The function that you write must use a helper function (either the num_vowels function from lecture, or a similar function that you...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT