Name: Anonymous 2021-03-26 16:54
The goal
The goal is to implement LISP's
Assumptions
* The cudder will always be provided in such a way that the result is non-NIL/non-NuRuPo.
* Maximum nesting level is 8 levels deep.
Examples
[1] https://en.wikipedia.org/wiki/CAR_and_CDR
[2] https://en.wikipedia.org/wiki/S-expression#Use_in_Lisp
The goal is to implement LISP's
car/cdr
[1] family of functions. Write a program that receives two inputs on the standard input, separated by spaces: the first (cudder) is an accessor in the form of ``c[ad]{0,32}r
''. The second is a LISP-style sexp[2], containing integers, potentially nested. Your program should execute the cudder on the sexp and print the result to standard output.Assumptions
* The cudder will always be provided in such a way that the result is non-NIL/non-NuRuPo.
* Maximum nesting level is 8 levels deep.
Examples
./cudder cdr "(1 2 3 4)"
(2 3 4)
./cudder car "(1 2 3 4)"
1
./cudder cddr "(1 2 3 4)"
(3 4)
./cudder cdddr "(1 2 3 4)"
(4)
./cudder cadr "(1 2 3 4)"
2
./cudder car "((1) 2 3 4)"
(1)
./cudder caar "((1) 2 3 4)"
1
./cudder cadr "(1 (2 3 4))"
(2 3 4)
[1] https://en.wikipedia.org/wiki/CAR_and_CDR
[2] https://en.wikipedia.org/wiki/S-expression#Use_in_Lisp