From e305992892172ddaebc74d07403b5732261676aa Mon Sep 17 00:00:00 2001 From: Brady McDonough Date: Thu, 7 Jan 2021 14:49:44 -0700 Subject: [PATCH] Added documentation comments --- tk/listlogic.scm | 6 ++++++ tk/ports.scm | 1 + 2 files changed, 7 insertions(+) diff --git a/tk/listlogic.scm b/tk/listlogic.scm index 0f2fce8..885e51f 100644 --- a/tk/listlogic.scm +++ b/tk/listlogic.scm @@ -14,8 +14,12 @@ (else (flatten-helper (cdr lst) (cons (car lst) acc) stk)))) +;; Flatten an input list, that is: if any entry in the list is itself a list +;;the entries in that list are 'unwrapped'. This occurs recursively. (define (flatten lst) (flatten-helper lst '() '())) +;; Evaluates (p (car ls1) (car ls2)) and accumulate into a return list as long +;;as that evauluation results in #t. (define (lp& p ls1 ls2) (let loop ((ls1 ls1) (ls2 ls2)) (cond ((not (and (pair? ls1) (pair? ls2))) @@ -25,6 +29,8 @@ (else '()) ))) +;; Collect entries from the beginning of the given lists as long as those +;;entries are equivalent according to (eqv?) (define (l& ls1 ls2) (cond ((eqv? ls1 ls2) ls1) (else (lp& eqv? ls1 ls2)))) diff --git a/tk/ports.scm b/tk/ports.scm index a6e82ee..2824b8e 100644 --- a/tk/ports.scm +++ b/tk/ports.scm @@ -2,6 +2,7 @@ #:export (port-rewind!) ) +;; Rewinds n chars back into port. Useful when parsing a character stack. (define (port-rewind! port chars n) (receive (rw rest) (split-at! chars n) (for-each (lambda (c) (unget-char port c)) rw) rest))