aboutsummaryrefslogtreecommitdiff
path: root/module/srfi
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-03-23 01:04:37 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2020-03-23 01:04:37 +0100
commit5a17028620ed7d940eb18ce7f4f552e12214ce12 (patch)
treecff8b21f8c080a8eb8a3107ce2eec10e05085d89 /module/srfi
parentChange style for continuing and continued long events HTML. (diff)
downloadcalp-5a17028620ed7d940eb18ce7f4f552e12214ce12.tar.gz
calp-5a17028620ed7d940eb18ce7f4f552e12214ce12.tar.xz
Hopefully fixed events-between.
Diffstat (limited to 'module/srfi')
-rw-r--r--module/srfi/srfi-41/util.scm14
1 files changed, 14 insertions, 0 deletions
diff --git a/module/srfi/srfi-41/util.scm b/module/srfi/srfi-41/util.scm
index 3101bc85..dda0fcd0 100644
--- a/module/srfi/srfi-41/util.scm
+++ b/module/srfi/srfi-41/util.scm
@@ -28,6 +28,10 @@
;; on. From there it knows that once it has found the first element
;; that satisfies our predicate all remaining elements satisfying pred
;; will be in direct succession.
+;; Does have some drawbacks, concider an event between 2020-01-01 and 2020-12-31.
+;; The collection is sorted on start time, and we want all events overlapping the
+;; interval 2020-02-01 to 2020-02-29. We would get the long event, but then probably
+;; stop because all regular small events in january.
(define-public (filter-sorted-stream pred stream)
(stream-take-while
pred (stream-drop-while
@@ -48,6 +52,16 @@
[else (filter-sorted-stream* pred? keep-remaining?
(stream-cdr stream))]))
+
+;; returns all object in stream from the first object satisfying
+;; start-pred, until the last object which sattisfies end-pred.
+(define-public (get-stream-interval start-pred end-pred stream)
+ (stream-take-while
+ end-pred (stream-drop-while
+ (negate start-pred)
+ stream)))
+
+
;; Finds the first element in stream satisfying pred.
;; Returns #f if nothing was found
(define-public (stream-find pred stream)