I want to write a function that just keeps the descending order numbers and gets rid of ascending ones.
For example:
(descending '(6 5 3 1 2 8))
should give me (6 5 3 1)
.
Thanks.
I want to write a function that just keeps the descending order numbers and gets rid of ascending ones.
For example:
(descending '(6 5 3 1 2 8))
should give me (6 5 3 1)
.
Thanks.
A list is the result of consing an object onto a list. Or an empty list.
What is consing? It is a built-in operation.
A descending list is the result of descend-consing an object onto a descending list. Or an empty list.
What is a descend-consing? It is a consing such that the resulting list is also descending:
Armed with this, the task is easy. We'll write the function
descending
which turns a list into a descending list, simply asWhat is the second argument expected by
descend-cons
? It must be a descending list.Can we create a descending list, from the list
'(y z ...)
? What function, that we have in our arsenal, would do this for us?