-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the branching arrows -<, -<<, --<, and -as-<. #279
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get rid of these changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in #280.
(-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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get rid of these changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in #280.
@@ -2658,7 +2742,7 @@ expects a list with n items as arguments | |||
|
|||
```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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get rid of these changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in #280.
Note: these changes were auto generated by create-docs.sh
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -1554,6 +1554,69 @@ and when that result is non-nil, through the next form, etc." | |||
(--> ,result ,form)) | |||
,@more)))) | |||
|
|||
(defmacro ---thread-each-and-collect (op x collector &optional forms) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use dash--
prefix for private functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in #280.
" | ||
(let ((value (make-symbol "value"))) | ||
`(let ((,value ,x)) | ||
(,collector ,@(--map (list op value it) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't value
be unquoted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole sexp is unquoted: ,@(--map (list op value...
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of course :) 👍
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 likeand
to 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: