Compare a list of strings: Difference between revisions

m
imported>Arakov
(2 intermediate revisions by 2 users not shown)
Line 677:
test1 lstC succeeds
test2 lstC fails</pre>
 
=={{header|Bruijn}}==
{{trans|Haskell}}
 
<syntaxhighlight lang="bruijn">
:import std/String .
 
all-eq? [land? (zip-with eq? 0 (tail 0))]
 
all-gt? [land? (zip-with lt? 0 (tail 0))]
 
# --- tests ---
 
list-a "abc" : ("abc" : {}("abc"))
 
list-b "abc" : ("def" : {}("ghi"))
 
:test (all-eq? list-a) ([[1]])
:test (all-eq? list-b) ([[0]])
:test (all-gt? list-a) ([[0]])
:test (all-gt? list-b) ([[1]])
</syntaxhighlight>
 
=={{header|C}}==
Line 2,708 ⟶ 2,730:
(formerly Perl 6)
 
In Raku, putting square brackets around an [[wp:Infix_notation|infix]] operator turns it into a listop that effectively works as if the operator had been butput in between all of the elements of the argument list ''(or in technical terms, it [[wp:Fold_(higher-order_function)|folds/reduces]] the list using that operator, while taking into account the operator's inherent [https://design.raku.org/S03.html#Operator_precedence associativity] and identity value)'':
 
<syntaxhighlight lang="raku" line>[eq] @strings # All equal
55

edits