Raku / doc

🦋 Raku documentation
https://docs.raku.org/
Artistic License 2.0
289 stars 291 forks source link

Document Range infix (elem), infix ∈ #3189

Open treyharris opened 4 years ago

treyharris commented 4 years ago

The problem

infix:(elem) and its synonym infix:<∈> are not documented for Range.

Current behavior:

$ perl6
To exit type 'exit' or '^D'
> so (3 ∈ (0..10))
True
> so (3 ∈ (5..10))
False
> so (3 ∈ (0..Inf))
False
> so (3 ∈ (0..*))
False
> so (3 ∈ (-Inf..Inf))
False
> so (3 ∈ Int.Range)
False
> so (3 ∈ (*..*))
False
lizmat commented 4 years ago

I would argue that some of these results are incorrect

JJ commented 4 years ago

@lizmat that, too.

treyharris commented 4 years ago

I agree, too. But the operator needs to be documented regardless.

Scimon commented 4 years ago

The problem is all the Set operators on Ranges turn them into lists and then put that into a set.

Which works OK for Integers and Strings (ish) but less well for other.

This is why I started Range::SetOps which I really should get round to finishing (it doesn't handle a bunch of edge cases).

https://modules.raku.org/dist/Range::SetOps:cpan:SCIMON

On Tue, 28 Jan 2020 at 20:16, Trey Harris notifications@github.com wrote:

I agree, too. But the operator needs to be documented regardless.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Raku/doc/issues/3189?email_source=notifications&email_token=AAATZ3RVGRQX2TGDE6NCUH3RACHCHA5CNFSM4KMXDFE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKEXWOA#issuecomment-579435320, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAATZ3UEJCMRT3YT73BSZPLRACHCHANCNFSM4KMXDFEQ .

-- Simon Proctor Cognoscite aliquid novum cotidie

http://www.khanate.co.uk/

2colours commented 1 year ago

Actually, (elem) with Ranges on the right handside is implemented as a thing on its own, see https://github.com/rakudo/rakudo/blob/15df5d8a85406a92a9cbcb994e1d424029007f39/src/core.c/set_elem.pm6#L67

Anyway, the implementation of it is too naive; not necessarily better than a naive Set-coercion would be. Perhaps it should be improved before it can be documented.