例如:
(int-to-binary 0) 返回 (0)
(int-to-binary 1) 返回(1)
(int-to-binary 2) 返回 (1 0)
(int-to-binary 13) 返回 (1 1 0 1)
提示: 你可以考虑使用LISP函数floor结合/、rem来解决这个问题。
以下是一些例子:
(my-member ’a ’()) 返回 NIL
(my-member ’a ’(c b a)) 返回 T
(my-member ’a ’(c b (a))) 返回 NIL
(因为a不是列表的元素,而是包含a的列表。)
这是第二个题目的延伸。编写一个新的LISP函数deep-member,如果给定的参数是给定列表的元素,或者在它的任何子列表中,则返回T,否则返回NIL。
以下是一些例子:
(deep-member ’a ’()) 返回 NIL
(deep-member ’a ’(c b a)) 返回 T
(deep-member ’a ’(c b (a))) 返回 T
(deep-member ’a ’(c b (1 (a)))) 返回 T
(deep-member ’a ’(c b (1 (d)))) 返回 NIL
https://stackoverflow.com/questions/22668217/decimal-to-binary-in-lisp-make-a-non-nested-list