reduce code size of recipes-by-ingredients by using 'filter'
This commit is contained in:
parent
98648ee163
commit
cc3cd7c19f
18
parse.scm
18
parse.scm
|
@ -63,19 +63,5 @@
|
||||||
|
|
||||||
(define recipes-by-ingredients
|
(define recipes-by-ingredients
|
||||||
(lambda (recipes search-ingredients)
|
(lambda (recipes search-ingredients)
|
||||||
(recipes-by-ingredients-rec recipes search-ingredients '())))
|
(filter (lambda (x) (contains-ingredients? x search-ingredients))
|
||||||
|
recipes)))
|
||||||
(define recipes-by-ingredients-rec
|
|
||||||
(lambda (recipes search-ingredients list)
|
|
||||||
(if (null? recipes)
|
|
||||||
list
|
|
||||||
(let* ((recipe (car recipes))
|
|
||||||
(ingredients (ingredients recipe))
|
|
||||||
(contains? (contains-ingredients? recipe
|
|
||||||
search-ingredients))
|
|
||||||
(new-list (if contains?
|
|
||||||
(cons recipe list)
|
|
||||||
list)))
|
|
||||||
(recipes-by-ingredients-rec (cdr recipes)
|
|
||||||
search-ingredients
|
|
||||||
new-list)))))
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user