Blankety-Blank Assignment
Create a Tom's lisp function fillin which takes two arguments,
both lists. It returns the first argument, with each member equal
to the atom _ replaced with a member of the second list, starting
with the first member and taking them in rotation. If the
first list contains fewer _ than the lenght of the second, only
the first part of the second list will be used. If it contains more,
members of the second list will be used more than once, still in rotation.
Place your definition(s) in a file which can be loaded into Tom's Lisp.
For instance:
lsp>(load "fillin.lsp")
rotate
lsp>(fillin '(Please leave the _ , _ , and the _ in the _)
--->'(box paint ducks))
(Please leave the box , paint , and the ducks in the box)
lsp>(fillin '(_ _ _ _) '(hi there how are things today))
(hi there how are)
lsp>(fillin '(A _ and a _ went by and the _ ran into the _ and fell on the _)
--->'(car truck))
(A car and a truck went by and the car ran into the truck and fell on the car)
lsp>(fillin '(nothing to do) '(this doesnt matter))
(nothing to do)
My solution used three cases, two of which are recursive.
While it is not a requirement, it may help to define a helper function which
simply moves the first member of a list to its end.
lsp>(rotate '(a b c))
(b c a)
lsp>(rotate '(x))
(x)
lsp>(rotate '(1 2 3 4 5 6 7 8))
(2 3 4 5 6 7 8 1)
You might want to use the built-in
append function to write this.
Submission
When your function works, is nicely formatted and documents,
submit it using
this form.