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

Add lengthable? #1280

Merged
merged 3 commits into from Sep 1, 2023
Merged

Add lengthable? #1280

merged 3 commits into from Sep 1, 2023

Conversation

primo-ppcg
Copy link
Contributor

Related: #1279

  • Add lengthable?
(lengthable? x)

Check if x is a bytes, indexed, or dictionary.
  • Speed up keys, values, and pairs, while allowing non-lengthable types
  • Allow non-lengthable types for reverse
  • Minor speed improvement for reverse!
  • Updates some docstrings missed in previous PRs

@sogaiu
Copy link
Contributor

sogaiu commented Sep 1, 2023

Various tests didn't turn up anything here 👍

Some manual trials:

$ ./build/janet
Janet 1.30.0-4cb1f616 linux/x64/gcc - '(doc)' for help

repl:1:> (lengthable? :a)
true

repl:2:> (lengthable? "a")
true

repl:3:> (lengthable? 1)
false

repl:4:> (lengthable? [:x :y])
true

repl:5:> (lengthable? (peg/compile '':a))
false

repl:6:> (lengthable? {:x 1})
true

@bakpakin bakpakin merged commit 51c0cf9 into janet-lang:master Sep 1, 2023
8 checks passed
@primo-ppcg primo-ppcg deleted the lengthable branch September 2, 2023 01:50
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.

None yet

3 participants