Compare a list of strings: Difference between revisions

correct ordering again
(correct ordering)
(correct ordering again)
Line 475:
1
</pre>
 
 
=={{header|BQN}}==
If grade up matches grade down, then all elements are equal.
 
If all are not equal and the list is invariant under sorting, then it is in ascending order.
<lang bqn>AllEq ← ⍋≡⍒
Asc ← ¬∘AllEq∧∧≡⊢
 
•Show AllEq ⟨"AA", "AA", "AA", "AA"⟩
•Show Asc ⟨"AA", "AA", "AA", "AA"⟩
 
•Show AllEq ⟨"AA", "ACB", "BB", "CC"⟩
•Show Asc ⟨"AA", "ACB", "BB", "CC"⟩</lang>
<lang bqn>1
1</lang>
 
[https://mlochbaum.github.io/BQN/try.html#code=QWxsRXEg4oaQIOKNi+KJoeKNkgpBc2Mg4oaQIMKs4oiYQWxsRXHiiKfiiKfiiaHiiqIKCuKAolNob3cgQWxsRXEg4p+oIkFBIiwgIkFBIiwgIkFBIiwgIkFBIuKfqQrigKJTaG93IEFzYyDin6giQUEiLCAiQUEiLCAiQUEiLCAiQUEi4p+pCgrigKJTaG93IEFsbEVxIOKfqCJBQSIsICJBQ0IiLCAiQkIiLCAiQ0Mi4p+pCuKAolNob3cgQXNjIOKfqCJBQSIsICJBQ0IiLCAiQkIiLCAiQ0Mi4p+pCg== Try It!]
 
=={{header|Bracmat}}==
Line 503 ⟶ 523:
In words, the tests do the following: test1 assigns the first element of the argument to the "first" and then looks for another element that is not equal to "first". If the search succeeds, test1 fails and if the search fails, test1 succeeds. Test2 searches for two consecutive elements where the second element is not greater than the first elemnt. If the search succeeds, test2 fails and if the search fails, test2 succeeds.
 
=={{header|BQN}}==
If grade up matches grade down, then all elements are equal.
 
If all are not equal and the list is invariant under sorting, then it is in ascending order.
<lang bqn>AllEq ← ⍋≡⍒
Asc ← ¬∘AllEq∧∧≡⊢
 
•Show AllEq ⟨"AA", "AA", "AA", "AA"⟩
•Show Asc ⟨"AA", "AA", "AA", "AA"⟩
 
•Show AllEq ⟨"AA", "ACB", "BB", "CC"⟩
•Show Asc ⟨"AA", "ACB", "BB", "CC"⟩</lang>
<lang bqn>1
1</lang>
 
[https://mlochbaum.github.io/BQN/try.html#code=QWxsRXEg4oaQIOKNi+KJoeKNkgpBc2Mg4oaQIMKs4oiYQWxsRXHiiKfiiKfiiaHiiqIKCuKAolNob3cgQWxsRXEg4p+oIkFBIiwgIkFBIiwgIkFBIiwgIkFBIuKfqQrigKJTaG93IEFzYyDin6giQUEiLCAiQUEiLCAiQUEiLCAiQUEi4p+pCgrigKJTaG93IEFsbEVxIOKfqCJBQSIsICJBQ0IiLCAiQkIiLCAiQ0Mi4p+pCuKAolNob3cgQXNjIOKfqCJBQSIsICJBQ0IiLCAiQkIiLCAiQ0Mi4p+pCg== Try It!]
 
<lang Bracmat> (test1=first.~(!arg:%@?first ? (%@:~!first) ?))
236

edits