My question is really one of logic more than anything, the task is to truncate a list to a given length in racket. That is, given a list (A B C), and a given length of 2, I would want a new list of (A B). The constraint being that we have a restricted list of available functions, of which I will put below. I apologies if this question is simple but I'm having a tough time and just cannot work out the sequence necessary. If someone could even just point me in the right direction, that would be wonderful.
List of Functions:
- cons, car, cdr, define, quote, if, cond, else
- Basic forms of Arithmetic (+, -, *, /)
- very basic tests (basic numeric comparisons, null?, list?, eq?)
I have already created a function that returns the length of a list, I also understand this will require some form of recursion.