From 7187d8e4bd16f802bfadd5575f248ca64859b79f Mon Sep 17 00:00:00 2001 From: Ed Langley Date: Sat, 18 Aug 2018 13:18:07 -0700 Subject: [PATCH] More tweaks to example --- README.org | 4 +++- lens.lisp | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index c9309de..ef6318a 100644 --- a/README.org +++ b/README.org @@ -4,7 +4,9 @@ This library provides a language for expressing data manipulations as the composition of more primitive operations. #+BEGIN_SRC lisp - DATA-LENS> (funcall (on (compress-runs :collector 'combine-matching-lists) + DATA-LENS> (funcall (on (alexandria:compose + (over (transform-tail (over (slice 1)))) + (compress-runs :collector 'combine-matching-lists)) (alexandria:compose (over (data-lens:juxt (data-lens:element 0) diff --git a/lens.lisp b/lens.lisp index 5408abd..52bf0de 100644 --- a/lens.lisp +++ b/lens.lisp @@ -102,6 +102,15 @@ (lambda (seq) (map 'list selector seq))) +(defun slice (start &optional end) + (lambda (it) + (subseq it start end))) + +(defun-ct transform-tail (fun) + (lambda (it) + (list* (car it) + (funcall fun (cdr it))))) + (defun-ct key-transform (fun key-get key-set) (lambda (it) (let ((key-val (funcall key-get it)))