Add the branching arrows -<, -<<, --<, and -as-<.#279
Add the branching arrows -<, -<<, --<, and -as-<.#279malaggan wants to merge 1 commit intomagnars:masterfrom malaggan:master
Conversation
|
Thank you for pointing me to this. I was not aware an issue was already open. How do you propose we proceed now? |
|
Well, as I said in the issue, I'm in favor of them. It looks like you've done a good and thorough job in this patch. But it's up to the Dash maintainers whether to accept it. |
|
@malaggan D: Did you change your mind? I was looking forward to being able to use these. |
|
@alphapapa No, I haven't changed my mind. I am committed to seeing this PR through and to addressing any concerns raised. I take my contributions very seriously, and I am thankful for the time everyone who reviews/comments on it invests. Kindly accept my apologies for the abrupt temporary closure of this PR. I had to temporarily close it because I remembered that I had to do something (non-technical) first. I will reopen the PR as soon as I can. |
| (-partition-after-pred #'oddp '()) ;; => '() | ||
| (-partition-after-pred #'oddp '(1)) ;; => '((1)) | ||
| (-partition-after-pred #'oddp '(0 1)) ;; => '((0 1)) | ||
| (-partition-after-pred (function oddp) '()) ;; => '() |
There was a problem hiding this comment.
Can we get rid of these changes?
| (-partition-before-pred #'oddp '()) ;; => '() | ||
| (-partition-before-pred #'oddp '(1)) ;; => '((1)) | ||
| (-partition-before-pred #'oddp '(0 1)) ;; => '((0) (1)) | ||
| (-partition-before-pred (function oddp) '()) ;; => '() |
There was a problem hiding this comment.
Can we get rid of these changes?
| ```el | ||
| (-map (-applify '+) '((1 1 1) (1 2 3) (5 5 5))) ;; => '(3 6 15) | ||
| (-map (-applify (lambda (a b c) `(,a (,b (,c))))) '((1 1 1) (1 2 3) (5 5 5))) ;; => '((1 (1 (1))) (1 (2 (3))) (5 (5 (5)))) | ||
| (-map (-applify (lambda (a b c) (\` ((\, a) ((\, b) ((\, c))))))) '((1 1 1) (1 2 3) (5 5 5))) ;; => '((1 (1 (1))) (1 (2 (3))) (5 (5 (5)))) |
There was a problem hiding this comment.
Can we get rid of these changes?
There was a problem hiding this comment.
Done in #280.
Note: these changes were auto generated by create-docs.sh.
There was a problem hiding this comment.
Yea, but I don't know why. I think your emacs version and the previous person's who run that are different and that makes the inconsistencies.
We really should build the docs on the CI env.
| (--> ,result ,form)) | ||
| ,@more)))) | ||
|
|
||
| (defmacro ---thread-each-and-collect (op x collector &optional forms) |
There was a problem hiding this comment.
use dash-- prefix for private functions
| " | ||
| (let ((value (make-symbol "value"))) | ||
| `(let ((,value ,x)) | ||
| (,collector ,@(--map (list op value it) |
There was a problem hiding this comment.
shouldn't value be unquoted?
There was a problem hiding this comment.
The whole sexp is unquoted: ,@(--map (list op value....
|
This pull request cannot be reopened, unfortunately, so I had to resubmit it (after all the comments here were addressed) at #280. Apologies for the inconvenience. |
Add parallel-threading macros inspired by https://github.com/rplevy/swiss-arrows. The general idea is the to complement the existing threading macros, which apply forms in sequence, to provide similar macros that apply forms in parallel.
For example:
(-< 3 list 1+ 1- (* 2))will produce(4 2 6), and(-< 3 + 1+ 1- (* 2))will produce12. The syntax is similar to the sequential threading macros (->, ->>, etc.) except that an extra parameter is needed: the "collector" that will take the forms as arguments. This choice was made, instead of returning a list, to allow for short-circuiting special forms likeandto be used.The use case I've personally encountered that motivated me to implement this was the need to pass the same value to several predicates and combine these predicates using
and:could be written as: