Question

Write a LISP function HASSUBS which receives a list “s” and checks for sublists. If it...

Write a LISP function HASSUBS which receives a list “s” and checks for sublists. If it has sublist return T, else return a NIL

0 0
Add a comment Improve this question Transcribed image text
Answer #1

(defun hassubs()
(append '(5.7 5.8 0.0) '(6.5 6.6 0.0) '(7.3 7.4 0.0) '(8.1 8.2 0.0))
)

(defun sublist()
(list '( (4 (1 2)) (5 (5 5)) (7 (3 1)) (1 (2 3)))
(define (sublist)
(map cadr list)))
)   

(setq hassubs sublists)
(if (== hassubs sublists)
(format t "~% T"))
(format t "~% NIL ~d " hassubs)

Add a comment
Know the answer?
Add Answer to:
Write a LISP function HASSUBS which receives a list “s” and checks for sublists. If it...
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
  • Write a function called avg_max that takes a list of lists (sublists may be empty) and...

    Write a function called avg_max that takes a list of lists (sublists may be empty) and return the average of the largest item in each sublist as a float. If a sublist is empty, do not consider it for the purposes of computing average. You may assume that everything inside a non-empty sublist is a number. You may assume that at least one sublist will be non-empty. Write a function called avg max that takes a list of lists (sublists...

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

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

  • 2. Write a LISP function COUNTLETS which takes a list and returns the number of top-level...

    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

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

  • 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

  • Write another function buddies(...) that receives a list (with at least 3 integer numbers), and returns...

    Write another function buddies(...) that receives a list (with at least 3 integer numbers), and returns the number of pairs of buddies in the list. We will define a “pair of buddies” to be the pair of elements that are contiguous in the list and that are equal, and also so that the contiguous elements to the pair are different (or the pair is in an extreme of the list). For example, [5,2,2,3] has 1 pair of buddies (the 2’s)...

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

  • In PYTHON: Write a function that receives a list of integers and returns the number of...

    In PYTHON: Write a function that receives a list of integers and returns the number of integers that are larger than the element immediately before them. For example, given [1,2,3,-5,0,-5,-10] the function should return 3 (since 1<2, 2<3, and -5<0).

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