diff options
author | Arun Isaac | 2023-10-14 23:38:58 +0100 |
---|---|---|
committer | Arun Isaac | 2023-10-14 23:38:58 +0100 |
commit | e200e606900328bea1c237287d55ccd1f2b3ff2f (patch) | |
tree | e2d6c328f5e96554cce6c3336eb50f0a785245b7 | |
parent | 82333d70f3a5dc64af99463516c5490bfd4e3894 (diff) | |
download | rent-in-london-e200e606900328bea1c237287d55ccd1f2b3ff2f.tar.gz rent-in-london-e200e606900328bea1c237287d55ccd1f2b3ff2f.tar.lz rent-in-london-e200e606900328bea1c237287d55ccd1f2b3ff2f.zip |
Use list-transduce.
list-transduce allows us to see desired house listings as soon as they
are found. We don't have to wait until all desired house listings are
processed.
* rent.scm (main): Use list-transduce.
-rw-r--r-- | rent.scm | 41 |
1 files changed, 23 insertions, 18 deletions
@@ -23,6 +23,7 @@ (srfi srfi-26) (srfi srfi-71) (srfi srfi-43) + (srfi srfi-171) (ice-9 match) (ice-9 regex) (ice-9 string-fun) @@ -460,21 +461,25 @@ Cycling distance to Wembley stadium: ~,1f km ;; - there is at least one tube station in the vicinity ;; - is not a bedsit ;; -;; Sort the listed houses newest advertisments last. -(list-houses - (filter (lambda (house) - (and (not (house-bills-included? house)) - (< (house-hours-live house) 100) - (not (house-shared? house)) - (<= (house-bedrooms house) 1) - (>= (house-rent house) 1200) - (<= (house-rent house) 1400) - (house-unfurnished? house) - (house-live? house) - (>= (house-maximum-tenants house) 2) - (not (null? (house-tube-stations house))) - (not (string-contains-ci (house-title house) "bedsit")))) - (sort (all-houses) - (lambda (house1 house2) - (> (house-hours-live house1) - (house-hours-live house2)))))) +;; Sort the listed houses newest advertisments first. +(format (current-output-port) + "~a houses~%" + (list-transduce (compose (tfilter (lambda (house) + (and (not (house-bills-included? house)) + (< (house-hours-live house) 100) + (not (house-shared? house)) + (<= (house-bedrooms house) 1) + (>= (house-rent house) 1200) + (<= (house-rent house) 1400) + (house-unfurnished? house) + (house-live? house) + (>= (house-maximum-tenants house) 2) + (not (null? (house-tube-stations house))) + (not (string-contains-ci (house-title house) "bedsit"))))) + (tlog (lambda (_ house) + (list-house house)))) + rcount + (sort (all-houses) + (lambda (house1 house2) + (< (house-hours-live house1) + (house-hours-live house2)))))) |