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

seq #33

Merged
merged 7 commits into from
Aug 17, 2022
Merged

seq #33

merged 7 commits into from
Aug 17, 2022

Conversation

lilactown
Copy link
Collaborator

Please answer the following questions and leave the below in as part of your PR.


Related #22

This PR implements the following:

  • Renames iterable? to seqable? and adds support for nil and js/undefined
  • Updates iterable to return an empty array when nil or undefined are passed
  • Adds a new seq function which is just like iterable but returns nil when the iterable is empty.
  • Updates first, second and rest to call iterable before destructuring.
  • Tests for seq

This now allows us to do things like the following:

(loop [evens []
       nums (range 10)]
  (if-some [x (first nums)]
    ,,,))

throw new Error(
"Illegal argument: assoc expects an odd number of arguments."
);
throw new Error('Illegal argument: assoc expects an odd number of arguments.');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some of these changes come from prettier reformatting. sorry for the noise. I hope it matches the style intended

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem

Comment on lines -222 to +220
return x instanceof String || Symbol.iterator in x;
return typeof x === 'string' || x === null || x === undefined || Symbol.iterator in x;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparently this was totally broken for strings before

@lilactown
Copy link
Collaborator Author

I think this is ready for review

@lilactown lilactown mentioned this pull request Aug 17, 2022
2 tasks
@borkdude borkdude merged commit bb82060 into squint-cljs:main Aug 17, 2022
borkdude added a commit that referenced this pull request Dec 24, 2022
borkdude pushed a commit that referenced this pull request Dec 24, 2022
borkdude added a commit that referenced this pull request Dec 24, 2022
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

Successfully merging this pull request may close these issues.

2 participants