Skip to content

Add tests for ffirst, fnext, last, nfirst, and nnext #86

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

Merged
merged 3 commits into from
Jun 16, 2025

Conversation

rafonsecad
Copy link
Contributor

No description provided.

Copy link
Member

@jeaye jeaye left a comment

Choose a reason for hiding this comment

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

Looking good! Just one request for another lazy case.

(is (= 0 (ffirst '([0 1] [2 3]))))
(is (= \a (ffirst ["ab" "cd"])))
(is (= \a (ffirst ["abcd"])))
(is (= \a (ffirst #{"abcd"}))))
Copy link
Member

Choose a reason for hiding this comment

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

I think it'd be good to cover a happy case for infinite seqs. For example, two come to mind:

  • (ffirst (repeat (range)))
  • (ffirst [(range)])

Same with nfirst.

Copy link
Contributor Author

@rafonsecad rafonsecad Jun 13, 2025

Choose a reason for hiding this comment

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

@jeaye for ffirst those cases are ok, but nfirst would work with a finite range

(nfirst (repeat (range 0 10))) ;; (1 2 3 4 5 6 7 8 9)

(nfirst (repeat (range))) ; is equal to (next (range))

Copy link
Member

Choose a reason for hiding this comment

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

Yep, do whichever tweaks you need for nfirst. 🙂

@rafonsecad
Copy link
Contributor Author

@jeaye, I updated the pull request. Let me know if we need another change

Copy link
Member

@jeaye jeaye left a comment

Choose a reason for hiding this comment

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

Looks great!

@jeaye jeaye merged commit ea7dd62 into jank-lang:main Jun 16, 2025
2 checks passed
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