Skip to content
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

cut does not treat <> in first slot as a function #185

Closed
holomorph opened this issue May 27, 2016 · 7 comments
Closed

cut does not treat <> in first slot as a function #185

holomorph opened this issue May 27, 2016 · 7 comments

Comments

@holomorph
Copy link
Contributor

holomorph commented May 27, 2016

For example

(mapcar (-cut <> 1 2 3) (list 'list 'vector 'string))

fails.

I suggest checking PARAMS and conditionally prepending funcall:

(if (eq (car params) '<>) (setq params (cons 'funcall params)))

Edit: that would also mean small fixes to -orfn and andfn

@Fuco1
Copy link
Collaborator

Fuco1 commented May 30, 2016

I'm not sure this is what cut is supposed to do. It creates partially applied functions (that is, filling in arguments), you are not filling in arguments.

This works:

(mapcar (-cut (lambda (f a b c) (funcall f a b c)) <> 1 2 3) (list 'list 'vector 'string))

Of course you know that... I'll have to think about it, but it doesn't make much sense when you can just write

(--map (funcall it 1 2 3)  (list 'list 'vector 'string))

@holomorph
Copy link
Contributor Author

I suppose it comes down to whether or not you want -cut to behave as in Scheme, i.e. whether you think it makes sense to be able to write things like in a Scheme. The additional shorthand of not having to write funcall seems nice to me.

@holomorph
Copy link
Contributor Author

alternatively, I don't think <> should be allowed in the first slot

@Fuco1
Copy link
Collaborator

Fuco1 commented Jun 12, 2016

I think I'll do what you suggested in the OP. This was modelled after SRFI 26 so I think we should have it compatible. I should also add the rest slot while at it. Or do you want to PR?

@holomorph
Copy link
Contributor Author

Nah, my PR would just be the one line in the original post anyways. Go ahead

Fuco1 added a commit that referenced this issue Jun 15, 2016
This follows the Scheme SRFI 26 notation.
@Fuco1
Copy link
Collaborator

Fuco1 commented Jun 15, 2016

Done. Thanks for the idea.

@Fuco1 Fuco1 closed this as completed Jun 15, 2016
@holomorph
Copy link
Contributor Author

o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants