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

(some) returns first truthy predicate result, not first truthy item #1350

Open
iacore opened this issue Jan 4, 2024 · 6 comments
Open

(some) returns first truthy predicate result, not first truthy item #1350

iacore opened this issue Jan 4, 2024 · 6 comments

Comments

@iacore
Copy link
Contributor

iacore commented Jan 4, 2024

repl:40:> (doc some)


    function
    boot.janet on line 2160, column 1

    (some pred ind & inds)

    Returns nil if (pred item) is false or nil for every item in ind. 
    Otherwise, returns the first truthy result encountered.

Is this intended? The return value isn't very useful this way.

@iacore
Copy link
Contributor Author

iacore commented Jan 5, 2024

I found find to do what I wanted. No idea if there is a function that maps to (all).

@sogaiu
Copy link
Contributor

sogaiu commented Jan 5, 2024

I agree that the docstring doesn't seem to match the actual behavior depending on specific arguments.

But I don't know what you mean by "return value isn't very useful":

$ janet
Janet 1.32.1-9142f38c linux/x64/gcc - '(doc)' for help
repl:1:> (some neg? [1 2 3 8])
nil
repl:2:> (some neg? [1 2 3 8 -1])
true

Doesn't this tell you something that was not necessarily known before the call?

@iacore
Copy link
Contributor Author

iacore commented Jan 5, 2024

But I don't know what you mean by "return value isn't very useful":

I mean (some ...) can easily just return true or false.

@sogaiu
Copy link
Contributor

sogaiu commented Jan 5, 2024

If the language was starting from scratch, may be a different choice might have been nicer.

Not so clear what the implications of changing behavior are at this point. But who knows...

@iacore
Copy link
Contributor Author

iacore commented Jan 5, 2024

how do i move this to /discussions/

@sogaiu
Copy link
Contributor

sogaiu commented Jan 5, 2024

I don't know -- I don't see an option in my view of this issue.

Perhaps it's reserved for some folks (like members of the janet-lang org)?

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