mirror of
https://github.com/fiddlerwoaroof/data-lens.git
synced 2025-11-08 18:26:32 +00:00
feat(on): make on more conformant with the Haskell function
This commit is contained in:
10
lens.lisp
10
lens.lisp
@ -269,10 +269,16 @@
|
|||||||
(apply ,fsym ,@args ,seq)))))
|
(apply ,fsym ,@args ,seq)))))
|
||||||
|
|
||||||
(defun-ct on (fun key)
|
(defun-ct on (fun key)
|
||||||
|
"Transform arguments with KEY and then apply FUN
|
||||||
|
|
||||||
|
> (eql (funcall (on 'equal 'car)
|
||||||
|
> '(\"a\" 1 2)
|
||||||
|
> '(\"a\" 2 e))
|
||||||
|
> t)"
|
||||||
(let ((fun (functionalize fun))
|
(let ((fun (functionalize fun))
|
||||||
(key (functionalize key)))
|
(key (functionalize key)))
|
||||||
(lambda (it)
|
(lambda (&rest its)
|
||||||
(funcall fun (funcall key it)))))
|
(funcall fun (mapcar key its)))))
|
||||||
|
|
||||||
(defun filler (length1 length2 fill-value)
|
(defun filler (length1 length2 fill-value)
|
||||||
(if (< length1 length2)
|
(if (< length1 length2)
|
||||||
|
|||||||
Reference in New Issue
Block a user