0

I do already have a function that counts the number of times that a letter occurs in a text. Now I am trying to do it for bigrams. Until now, I have

CountDi(txt, L1, L2)={
  local(ct,len,v);
  ct=0;len=#txt;
  v=Vecsmall(txt);
  for(k=1,len, if(v[k] == Vecsmall(L1)[1] || v[k] == Vecsmall(L1)[1] + 32));
  for(j=1, len, if(v[j] == Vecsmall(L2)[1] || v[j] == Vecsmall(L2)[1] && v[j] ==v[k] + 1 , ct = ct + 
    1)); 
  return(ct)
 };

This is in PARI/GP, and L1 and L2 are to be given in the for "A", for example. What happens is that I'm not being succeeded, because for every letters L1 and L2, the function returns always 0, but I'm not getting why. Thanks in advance.

Anonymous
  • 49
  • 1
  • 9

0 Answers0