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
Wouldn’t it be nice if whenever we messed up our life we could simply press ‘Ctrl Alt Delete’ and start all over?
Orlov [11]
Sure, if you want to delete things
8 0
4 years ago
Read 2 more answers
If you fail a course as a MAIN (residency) course, you can repeat that course as either a MAIN (residency) or an online (IG or I
Elina [12.6K]

Answer: False

Explanation:

The statement that "you fail a course as a MAIN (residency) course, you can repeat that course as either a MAIN (residency) or an online (IG or IIG) course" is false.

It should be noted that if one fail a course as a residency course, the course can only be repeated as a main (residency) course and not an online course. When a course is failed, such course has to be repeated the following semester and this will give the person the chance to improve their GPA.

5 0
3 years ago
What would be one advantage and one risk of using an electric car?
Lemur [1.5K]
One advantage of using an electric car would be not having to pay for gas, one risk would be it malfunctioning.
4 0
3 years ago
Read 2 more answers
PLZ ANSWER ASAP WILL GIVE BRAINLYEST
malfutka [58]

Answer: Navigation

Explanation:

the Navigation pane

3 0
2 years ago
carleehilyard 3x6?carleehilyard 3x6?carleehilyard 3x6?carleehilyard 3x6?carleehilyard 3x6?carleehilyard 3x6?carleehilyard 3x6?ca
BaLLatris [955]

Answer:

A)

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • The memory allocated for a float value is ____ bytes.
    9·1 answer
  • According to the ________ definition of organizations, an organization is seen as a means by which primary production factors ar
    14·1 answer
  • You have found an old dusty computer in your basement that you can identify as an original IBM PC. You ask your friend if he kno
    15·1 answer
  • The______for our newest game keeps changing as we develop our concept and refine our goals.
    11·2 answers
  • Which line of code will print Python is cool! on the screen?
    9·2 answers
  • Eugenia told her coach that she was too tired to play. As soon as she said it, she realized that she had made a big mistake. She
    12·1 answer
  • Complete the crossword puzzle.
    12·2 answers
  • Here we have a program which is calling the subtract function to calculate the difference between two numbers. The value from th
    7·1 answer
  • _____________programs and features are often integrated into video editing software.
    13·1 answer
  • A _ is the acknowledgment of a potential noncomformity, or an opinion regarding an issue that is not covered by a standard
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!