i am new to lisp and in my code i want to convert 3 first bit to integer and check if number of ones in next bits is equal to that or not this is my code:
(defun new (vi n res)
(cond ((= vi nil) (cond ((= 0 res) t) ))
((= 2 n) (new (cdr vi) 1 (* (car vi) 4)))
((= 1 n) (new (cdr vi) 0 (+ (res) (* (car vi) 2))))
((= 0 n) (new (cdr vi) -1 (+ (res) (car vi ))))
((= vi nil) (nil))
((= -1 n) (new (cdr vi) -1 (- res (car vi))))))
i wanted to test it but when i write it:
(new ( 0 1 0 0 0 0 1 0 0 1 0) 2 0 )
it errors 0 is not a function i tried this one :
(new (list `0 `1 `0 `0 `0 `0 `1 `0 `0 `1 `0) 2 0 )
but it errors
SBCL shows these warnings compiling your function:
; in: DEFUN NEW
; (= VI NIL)
;
; caught WARNING:
; Constant NIL conflicts with its asserted type NUMBER.
; See also:
; The SBCL Manual, Node "Handling of Types"
; in: DEFUN NEW
; (NIL)
;
; caught WARNING:
; The function NIL is undefined, and its name is reserved by ANSI CL so that even
; if it were defined later, the code doing so would not be portable.
; (RES)
;
; caught STYLE-WARNING:
; undefined function: COMMON-LISP-USER::RES
;
; compilation unit finished
; Undefined functions:
; NIL RES
; caught 2 WARNING conditions
; caught 1 STYLE-WARNING condition