Longest common prefix: Difference between revisions
Content added Content deleted
Alpha bravo (talk | contribs) m (Added AutoHotkey) |
Alpha bravo (talk | contribs) m (Added AutoHotkey) |
||
Line 673:
=={{header|AutoHotkey}}==
<lang AutoHotkey>
for num, v in StrSplit(data.1)
for i, word in data
if (SubStr(word, 1, num) <> SubStr(data.1, 1, num))
return SubStr(word, 1, num-1)
return SubStr(word, 1, num)
}</lang>
Examples:<lang AutoHotkey>MsgBox % ""
. "`n"
. "`n"
. "`n"
. "`n"
. "`n"
. "`n"
. "`n"
. "`n" lcp(["prefix","suffix"])
. "`n" lcp(["foo","foobar"])
return</lang>
{{out}}
Line 697 ⟶ 699:
cheese
foo</pre>
=={{header|AWK}}==
|