Compare a list of strings: Difference between revisions

No edit summary
Line 2,178:
dup len swap 1 get rot repeat == /# put 0 (false) in the pile, indicating that they are not repeated strings #/
</lang>
 
=={{header|Picat}}==
<lang Picat>main =>
Lists = [["AA","BB","CC"],
["AA","AA","AA"],
["AA","CC","BB"],
["AA","ACB","BB","CC"],
["single_element"],
[]],
foreach(L in Lists)
Same = all_same(L).cond(true,false),
Sorted = sorted(L).cond(true,false),
printf("%-18w all_same:%-5w sorted:%-5w\n",L,Same,Sorted)
end.
 
all_same([]).
all_same([_]).
all_same([A,B|Rest]) :-
A == B,
all_same([B|Rest]).</lang>
 
{{out}}
<pre>[AA,BB,CC] all_same:false sorted:true
[AA,AA,AA] all_same:true sorted:true
[AA,CC,BB] all_same:false sorted:false
[AA,ACB,BB,CC] all_same:false sorted:true
[single_element] all_same:true sorted:true
[] all_same:true sorted:true </pre>
 
=={{header|PicoLisp}}==
495

edits