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]
3 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]3 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
WHO SAYS BUP ALL THE TIME ​
Delvig [45]

Answer:

Mario

Explanation:

7 0
3 years ago
Who create and developed castlevania?
Ray Of Light [21]
The game was made by Nintendo. 
Developers: Koji Igarashi<span> </span>Hideo Kojima<span> </span>Michiru Yamane<span> </span><span>Yuzo Koshiro. </span>
6 0
3 years ago
A _______________ is a field that contains data unique to a record.
Andru [333]

A primary key is a field that contains data unique to a record

8 0
3 years ago
calculate how many turns of cable you will need on the drum for your cage and skip to move up and down by 500 m​
anyanavicka [17]
Physics. only one, if the drum is 500m around... 50 turns. you will need on the drum for your cage and skip to move up and down by 500m. 500/18.84= 26.5.

Mark me as brainliest pls..... :)
5 0
2 years ago
Who knows songs that are sad,happy,excited, and calm
anzhelika [568]

sad-

you broke me first

can we kiss forever

love the way you lie

happy-

Say Yes

Valerie

Walking on Sunshine

excited-

who let the dogs out

September

calm-

heather

put your records on

lonely

5 0
2 years ago
Other questions:
  • Which cell formatting is most likely to use $?
    11·2 answers
  • 4
    10·1 answer
  • Ideally an entity identifier is composed of _____ attribute(s).
    11·1 answer
  • This method of advertising is expensive but can be the most effective method.
    15·1 answer
  • I have wings, I am able to fly, I‘m not a bird yet I soar high in the sky. What am I?
    14·2 answers
  • Determine the number of cache sets (S), tag bits (t), set index bits (s), and block offset bits (b) for a 1024-byte 4-way set as
    5·1 answer
  • A spreadsheet contains the maximum weight and maximum height for fifty dog breeds. The breeds are located in rows, and the weigh
    5·1 answer
  • True or false scientists investigate and seek to explain the natural world
    14·1 answer
  • My assignment asks me to write a python program using if, elif, and else that takes a user's salary and calculates the tax based
    7·1 answer
  • Are programs that understand physics and/or hardware embedded? for example, one that uses finite-element methods to predict flui
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!