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

Diagraphs for checking sortedness #741

Closed
4 tasks
AMiller42 opened this issue Feb 21, 2022 · 4 comments · Fixed by #775
Closed
4 tasks

Diagraphs for checking sortedness #741

AMiller42 opened this issue Feb 21, 2022 · 4 comments · Fixed by #775
Labels
difficulty: easy Very simple and won't take very long at all. enhancement New feature or request request: element A request to create new element(s)

Comments

@AMiller42
Copy link
Member

We should have some diagraphs for checking various sortednesses. At the moment, just checking if a list/string is sorted requires 3 bytes: :s=. Having this as a diagraph would be nice, and while we're at it, I think we should add a few more. I think we should add diagraphs to check if a list/string:

  • Is sorted, e.g. [1,2,3] → 1 [3,2,1] → 0 [1,3,2] → 0
  • Is reverse sorted, e.g. [1,2,3] → 0 [3,2,1] → 1 [1,3,2] → 0
  • Is either sorted/reverse sorted, e.g. [1,2,3] → 1 [3,2,1] → 1 [1,3,2] → 0
  • Is unsorted, e.g. [1,2,3] → 0 [3,2,1] → 0 [1,3,2] → 1

Let me know if you need any elaboration. Feel free to propose similar diagraphs and I'll add them to the list.

@AMiller42 AMiller42 added difficulty: easy Very simple and won't take very long at all. request: element A request to create new element(s) enhancement New feature or request labels Feb 21, 2022
@lyxal
Copy link
Member

lyxal commented Feb 22, 2022

Just on the "is unsorted" digraph - how would you define sorted? Because [1, 3, 2] could be considered sorted by some sort of ordering.

@AMiller42
Copy link
Member Author

Just on the "is unsorted" digraph - how would you define sorted? Because [1, 3, 2] could be considered sorted by some sort of ordering.

This is pretty much what I had in mind:

Sorted: :s⁼
Reverse Sorted: :sṘ⁼
Sorted/Reverse Sorted: ₌‡s⁼≬sṘ⁼∨
Unsorted: ₌‡s⁼≬sṘ⁼∨¬

@pxeger
Copy link
Collaborator

pxeger commented Feb 24, 2022

If there were a modifier for "is equal after applying", then an equivalent effect could be achieved, but with much a more general builtin.

@AMiller42
Copy link
Member Author

If there were a modifier for "is equal after applying", then an equivalent effect could be achieved, but with much a more general builtin.

I agree, this is probably a much better idea

lyxal added a commit that referenced this issue Mar 9, 2022
Based on @pxeger's suggestion in #741

And yes, you can have modifiers that are also digraphs. Believe it or not, I wrote the parser with digraphic modifiers in mind.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: easy Very simple and won't take very long at all. enhancement New feature or request request: element A request to create new element(s)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants