Skip to content

Conversation

@rwtolbert
Copy link
Contributor

add examples for keep

@bakpakin bakpakin merged commit 0b51f5c into janet-lang:master Jan 16, 2025
1 check passed
@sogaiu
Copy link
Collaborator

sogaiu commented Jan 16, 2025

@rwtolbert @bakpakin

Although the last example sort of works:

# operates on values in table
(keep (fn [x] (when (> x 1) (* x x))) @{:foo 1 :bar 2 :baz 3}) # -> @[4 9]

I'm not sure it's such a good idea to advertise this.

Depending on the Janet version, the result may differ:

$ janet
Janet 1.37.1-60d9f977 linux/x64/gcc - '(doc)' for help
repl:1:> (map + {:a 1 :b 2})
@[2 1]
$ ./build/janet
Janet 1.28.0-dev-909c9060 linux/x64/gcc - '(doc)' for help
repl:1:> (map + {:a 1 :b 2})
@[1 2]

The docstring mentions "indexed collection ind" which arguably applies to "array and tuple" as indexed?'s docstring is:

Check if x is an array or tuple.

But should that be the case for a table or struct?

@rwtolbert
Copy link
Contributor Author

Yeah, I just added it because it "worked" but I can see the advantage of making it fail in the core and then remove this example.

@sogaiu sogaiu mentioned this pull request Jan 17, 2025
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.

3 participants