1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nuetrik [128]
4 years ago
6

Code the function (insertNth list N insValue) which constructs a new list by inserting the specified insValue into the list afte

r the Nth top-level value (relative to 1).Example:> (insertNth '(X Y Z) 2 'FUN)(X Y FUN Z)> (insertNth '(X Y Z) 4 'FUN)(X Y Z)
Computers and Technology
1 answer:
-BARSIC- [3]4 years ago
3 0

Answer:

Explanation:

Function algorithm is coded below

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

2. Replace in Function

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

(defun replace-all (string part replacement &key (test #'char=))

 "Returns a new string in which all the occurrences of the part is replaced with replacement."

 (with-output-to-string (out)

   (loop with part-length = (length part)

         for old-pos = 0 then (+ pos part-length)

         for pos = (search part string

                           :start2 old-pos

                           :test test)

         do (write-string string out

                          :start old-pos

                          :end (or pos (length string)))

         when pos do (write-string replacement out)

         while pos)))

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

3. Insert After

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

(defun insert-after (lst index newelt)

(push newelt (cdr (nthcdr index lst)))

lst)

(insert-after '(a c d) 0 'b) => (A B C D)

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

4. insertNth

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

(defun insertNth(number index list)

 (do ((head '() (list* (first tail) head))

      (tail list (rest tail))

      (index index (1- index)))

     ((zerop index)

      (nreconc head (list* (+ number (first tail))

                           (rest tail))))))

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

5. InsertAfterAll

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

(defun InsertAfterAll (a v)

  (if (null v) (cons a nil) (cons (car v) (endcons a (cdr v)))))

(endcons 'a '(b c d))

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

You might be interested in
What should you consider when thinking about your target audience?
inysia [295]
Hi,


The answer is all of the above. Its best to know your audience as best as you can that way you are able to think about it better.

Hope this helps.
r3t40
6 0
4 years ago
What does the word complacency mean ?
bulgar [2K]

Answer:

a feeling of smug or uncritical satisfaction with oneself or one's achievements.

Explanation:

8 0
4 years ago
Read 2 more answers
Both instructions and data in a digital<br>computer are represented as binary<br>digits. True False​
MrRissso [65]

Answer:

False

Explanation:

insturctions are represented in binary numbers, data are represented in decimal numbers.

6 0
3 years ago
Which two wildcard masks are required in an extended access list entry that blocks the traffic from network 192.168.20.0/26 to n
Jobisdone [24]

Answer:

The two wildcard masks that are required in an extended access list entry that blocks the traffic from network 192.168.20.0/26 to network 172.16.32.0/28 is 0.0.0.63 and 0.0.0.15

Explanation:

To identify the wild cards simply look slash number. Regardless of the netmask number, the corresponding wildcard mask for the slash /26 and /28 are 0.0.0.63 and 0.0.0.15.

8 0
4 years ago
Billy needs to type a bibliography/reference page for the report that he just typed. Which paragraph format should he use?
Olin [163]
He should use a MLA format

3 0
3 years ago
Other questions:
  • Which career professional and creates large data base and makes the data base with other systems
    13·1 answer
  • 38. Which of the following best describes why e-mail spoofing is easily executed? a. SMTP lacks an adequate authentication mecha
    15·1 answer
  • 15. In cell D6, enter a formula to calculate the percentage of High Priority Customers Sales out of All Customers 2016 sales. (T
    11·1 answer
  • Input numbers and segregate them by placing their values into even or odd vectors based upon their value being even or odd. Then
    12·1 answer
  • What does pdf stand for in computer terms?
    15·1 answer
  • Two words are a ""reverse pair"" if each is the reverse of the other. Write a program that finds all the reverse pairs in the wo
    12·1 answer
  • AW Computing uses a private sharing model for cases. A select group of five users need read/write access to all cases with a spe
    8·1 answer
  • Select the correct locations on the image. Adrian wants to delve into database administration. Which certifications would help h
    5·1 answer
  • 1) Given what you have learned about computers and information technology thus
    6·1 answer
  • How to install specific version of create-react-app so.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!