Create a function my_merge
to merge two lists of numbers.
(The name merge
is already a standard lisp
function).
My_merge
should take two arguments. It assumes that each argument is
a list of numbers sorted in ascending order. There may be
repeated members, and the lists need not be the same length.
The function returns a sorted list containing all the items from
either input list.
For instance:
[7]> (my_merge '(4 9 18 32 32 45 59) '(1 2 15 15 16 18 21 33))
(1 2 4 9 15 15 16 18 18 21 32 32 33 45 59)
[8]> (my_merge '(4 5 67) '(11))
(4 5 11 67)
[9]> (my_merge '() '(4 9 11 8))
(4 9 11 8)
[10]> (my_merge () ())
NIL
[11]> (my_merge '(34) '(10))
(10 34)
Place the definition of your function in a file which can be
load
ed by clisp. Please observe the following:
merge
or sort
functions.
You will probably want to use a cond
to consider several cases.
You will have a basis case when one of the
argument lists is empty.
When both lists are non-empty, consider that the merge of two sorted lists can be constructed as follows:
Submit your program using the form here.