7 lines
203 B
Text
7 lines
203 B
Text
|
|
fcn encode(text){ //-->List
|
||
|
|
st:=["a".."z"].pump(Data); //"abcd..z" as byte array
|
||
|
|
text.reduce(fcn(st,c,sink){
|
||
|
|
n:=st.index(c); sink.write(n); st.del(n).insert(0,c); },st,sink:=L());
|
||
|
|
sink;
|
||
|
|
}
|