Convert Character Substrings to Numeric
APL (Dyalog Extended), 8 7 6 bytesSBCS



Anonymous infix function. Takes s as left argument and w as a list of strings as right argument.

∪⍛⍳⍨↑¨


Try it online!

↑ take the first s characters from…
 ¨ each string in w

∪⍛…⍨ in the list of the ∪&zwj;nique strings in that…
 ⍳ find the ɩndex of the first occurrence of each string