mirror of
https://github.com/fiddlerwoaroof/data-lens.git
synced 2025-11-08 10:16:32 +00:00
feat: calling and calling*
This commit is contained in:
@ -344,6 +344,11 @@
|
|||||||
`(lambda (,first-arg)
|
`(lambda (,first-arg)
|
||||||
(funcall (functionalize ,fun) ,first-arg ,@args))))
|
(funcall (functionalize ,fun) ,first-arg ,@args))))
|
||||||
|
|
||||||
|
(defmacro calling* (fun &rest args)
|
||||||
|
(alexandria:with-gensyms (last-arg)
|
||||||
|
`(lambda (,last-arg)
|
||||||
|
(funcall (functionalize ,fun) ,@args ,last-arg))))
|
||||||
|
|
||||||
(defmacro applying (fun &rest args)
|
(defmacro applying (fun &rest args)
|
||||||
(alexandria:with-gensyms (seq fsym)
|
(alexandria:with-gensyms (seq fsym)
|
||||||
`(let ((,fsym (functionalize ,fun)))
|
`(let ((,fsym (functionalize ,fun)))
|
||||||
|
|||||||
@ -20,7 +20,8 @@
|
|||||||
#:maximizing #:zipping #:applying #:splice-elt
|
#:maximizing #:zipping #:applying #:splice-elt
|
||||||
#:transform-elt #:denest #:op #:defalias #:<> #:<>1 #:== #:•
|
#:transform-elt #:denest #:op #:defalias #:<> #:<>1 #:== #:•
|
||||||
#:∘ #:suffixp #:functionalize #:inc #:group-by #:keys
|
#:∘ #:suffixp #:functionalize #:inc #:group-by #:keys
|
||||||
#:conj #:disj #:delay #:of-type #:transform))
|
#:conj #:disj #:delay #:of-type #:transform #:calling*
|
||||||
|
#:calling))
|
||||||
|
|
||||||
(defpackage :data-lens.transducers.internals
|
(defpackage :data-lens.transducers.internals
|
||||||
(:use :cl)
|
(:use :cl)
|
||||||
|
|||||||
12
t/lens.lisp
12
t/lens.lisp
@ -284,3 +284,15 @@
|
|||||||
(5am:is (equal (funcall (data-lens:transform 1)
|
(5am:is (equal (funcall (data-lens:transform 1)
|
||||||
(data-lens:juxt '1- 'identity '1+))
|
(data-lens:juxt '1- 'identity '1+))
|
||||||
'(0 1 2))))
|
'(0 1 2))))
|
||||||
|
|
||||||
|
(5am:def-test calling (:suite :data-lens.lens :depends-on (and functionalize))
|
||||||
|
(5am:is (equal (funcall (data-lens:calling #'- 1) 3)
|
||||||
|
2))
|
||||||
|
(5am:is (equal (funcall (data-lens:calling #'- 2 1) 3)
|
||||||
|
0)))
|
||||||
|
|
||||||
|
(5am:def-test calling* (:suite :data-lens.lens :depends-on (and functionalize))
|
||||||
|
(5am:is (equal (funcall (data-lens:calling* #'- 3) 1)
|
||||||
|
2))
|
||||||
|
(5am:is (equal (funcall (data-lens:calling* #'- 3 2) 1)
|
||||||
|
0)))
|
||||||
|
|||||||
Reference in New Issue
Block a user