Compare a list of strings: Difference between revisions

Add SenseTalk
(→‎version 2: fixed closing tags for a template.)
(Add SenseTalk)
Line 2,396:
end for;
end func;</lang>
 
=={{header|SenseTalk}}==
<lang sensetalk>analyze ["AA","BB","CC"]
analyze ["AA","AA","AA"]
analyze ["AA","CC","BB"]
analyze ["AA","ACB","BB","CC"]
analyze ["single_element"]
 
to analyze aList
put "List: " & aList
put " " & (if allEqual(aList) then "IS" else "Is NOT") && "all equal"
put " " & (if isAscending(aList) then "IS" else "Is NOT") && "strictly ascending"
end analyze
 
to handle allEqual strings
return the number of items in the unique items of strings is less than 2
end allEqual
 
to handle isAscending strings
repeat with n = 2 to the number of items in strings
if item n of strings isn't more than item n-1 of strings then
return False
end if
end repeat
return True
end isAscending</lang>
{{Out}}
<pre>
List: ["AA","BB","CC"]
Is NOT all equal
IS strictly ascending
List: ["AA","AA","AA"]
IS all equal
Is NOT strictly ascending
List: ["AA","CC","BB"]
Is NOT all equal
Is NOT strictly ascending
List: ["AA","ACB","BB","CC"]
Is NOT all equal
IS strictly ascending
List: ["single_element"]
IS all equal
IS strictly ascending
</pre>
 
=={{header|Sidef}}==