diff --git a/recipes/remove-element-from-list.md b/recipes/remove-element-from-list.md index 1e5f531..d2b73bd 100644 --- a/recipes/remove-element-from-list.md +++ b/recipes/remove-element-from-list.md @@ -8,14 +8,13 @@ given predicate procedure. ## Solution ```Scheme -(define (remove fn list) - (let iter ((list list) (result '())) - (if (null? list) +(define (remove fn lst) + (let loop ((lst lst) (result '())) + (if (null? lst) (reverse result) - (let ((item (car list))) - (if (fn item) - (iter (cdr list) result) - (iter (cdr list) (cons item result))))))) + (let ((item (car lst))) + (loop (cdr lst) + (if (fn item) result (cons item result))))))) ``` Credit [Jakub T. Jankiewicz](https://jcubic.pl/me)