aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-10-05 23:58:03 +0200
committerHugo Hörnquist <hugo@hornquist.se>2019-10-05 23:58:03 +0200
commit68dfd8bb5abcc449500614c46566ffa4a83177a4 (patch)
treee1259834ad04db9fe2db7fec526cf4fd52b26990
parentFix day-stream, and in effect terminal output. (diff)
downloadcalp-68dfd8bb5abcc449500614c46566ffa4a83177a4.tar.gz
calp-68dfd8bb5abcc449500614c46566ffa4a83177a4.tar.xz
Documentation of stream behavior.
-rw-r--r--module/srfi/srfi-41/util.scm14
-rw-r--r--module/vcomponent/group.scm5
2 files changed, 16 insertions, 3 deletions
diff --git a/module/srfi/srfi-41/util.scm b/module/srfi/srfi-41/util.scm
index 050e1d2e..be363146 100644
--- a/module/srfi/srfi-41/util.scm
+++ b/module/srfi/srfi-41/util.scm
@@ -24,11 +24,19 @@
(define-public (stream-insert < item s)
(interleave-streams < (list (stream item) s)))
-(define-public (filter-sorted-stream proc stream)
+;; Requires that stream is a total order in regards to what we filter
+;; 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.
+(define-public (filter-sorted-stream pred stream)
(stream-take-while
- proc (stream-drop-while
- (negate proc) stream)))
+ pred (stream-drop-while
+ (negate pred) stream)))
+
+;; Simmilar to the regular @code{filter-sorted-stream}, but once an
+;; element satisfies @code{keep-remaning?} then the remaining tail
+;; of the stream is all assumed to be good.
(define-public (filter-sorted-stream* pred? keep-remaining? stream)
(cond [(stream-null? stream) stream-null]
[(keep-remaining? (stream-car stream)) stream]
diff --git a/module/vcomponent/group.scm b/module/vcomponent/group.scm
index 7733d981..46160a3a 100644
--- a/module/vcomponent/group.scm
+++ b/module/vcomponent/group.scm
@@ -20,6 +20,11 @@
(let ((head (stream-take-while (ein? day) stream))
(tail
+ ;; This is a filter, instead of a stream-span together with head,
+ ;; since events can span multiple days.
+ ;; This starts with taking everything which end after the beginning
+ ;; of tommorow, and finishes with the rest when it finds the first
+ ;; object which begins tomorow (after midnight, exclusize).
(filter-sorted-stream*
(lambda (e) (time<? tomorow (attr e 'DTEND)))
(lambda (e) (time<=? tomorow (attr e 'DTSTART)))