how to delete an element from a list ex:- list=[1 2 3 4]
I have come up with some code.I think I got wrong somewhere.
(define delete item (lambda
This code seems to work just fine, but only deletes an element that should be in the list:
(define (delete element lst) (let loop ([temp lst]) (if (= element (car temp)) (cdr temp) (cons (car temp) (loop (cdr temp))))))