git.fiddlerwoaroof.com
Browse code

More tweaks to example

Ed Langley authored on 18/08/2018 20:18:07
Showing 2 changed files
... ...
@@ -4,7 +4,9 @@ This library provides a language for expressing data manipulations as
4 4
 the composition of more primitive operations.
5 5
 
6 6
 #+BEGIN_SRC lisp
7
-  DATA-LENS> (funcall (on (compress-runs :collector 'combine-matching-lists)
7
+  DATA-LENS> (funcall (on (alexandria:compose
8
+                           (over (transform-tail (over (slice 1))))
9
+                           (compress-runs :collector 'combine-matching-lists))
8 10
                           (alexandria:compose 
9 11
                            (over (data-lens:juxt
10 12
                                   (data-lens:element 0)
... ...
@@ -102,6 +102,15 @@
102 102
   (lambda (seq)
103 103
     (map 'list selector seq)))
104 104
 
105
+(defun slice (start &optional end)
106
+  (lambda (it)
107
+    (subseq it start end)))
108
+
109
+(defun-ct transform-tail (fun)
110
+  (lambda (it)
111
+    (list* (car it)
112
+           (funcall fun (cdr it)))))
113
+
105 114
 (defun-ct key-transform (fun key-get key-set)
106 115
   (lambda (it)
107 116
     (let ((key-val (funcall key-get it)))