txlyre 2 недель назад
Родитель
Сommit
0677980ffa
2 измененных файлов с 26 добавлено и 3 удалено
  1. 10 3
      jk.c
  2. 16 0
      readme.md

+ 10 - 3
jk.c

@@ -2138,16 +2138,23 @@ Nt*PPatom(Pt*parser){Tkt*tok=Plook(parser,0);
       node=Nnl(Vna(r));}BR;}
   if(!node)Perror(parser,"parse");
   Peat(parser);R node;}
+B isunb(St*st,S s){if(st->args->data){Ar*args=Ai(st->args,-1);
+    Z argc=args->length-1;
+    if(argc==2&&strcmp(s,"y")==0)R F;
+    elif(strcmp(s,"x")==0)R F;}
+  elif(Thas(st->env,s))R F;R T;}
 Nt*PPa(Pt*parser,Nt*a,enum Tkt tag){Tkt*tok;
-  if((tok=Plook(parser,0))&&(tok->tag==tag||(tag==T_NUM&&tok->tag==T_BNUM))){Ar*as=An();
+  if((tok=Plook(parser,0))&&(tok->tag==tag||(tag==T_NUM&&tok->tag==T_BNUM))){if(tag==T_NAME&&!isunb(parser->st,tok->text))R N;
+    Ar*as=An();
     Ap(as,a->v);
-    do{a=PPatom(parser);
+    do{if(tag==T_NAME&&tok->tag==T_NAME&&!isunb(parser->st,tok->text))BR;
+      a=PPatom(parser);
       Ap(as,a->v);}WH((tok=Plook(parser,0))&&(tok->tag==tag||(tag==T_NUM&&tok->tag==T_BNUM)));R Nnl(Vna(as));}
   R N;}
 Nt*_PPnoun(Pt*parser){Nt*n;
   Nt*a=PPatom(parser);
   if(a->tag==N_LITERAL&&a->v->tag==NUM&&(n=PPa(parser,a,T_NUM)))R n;
-  elif(a->tag==N_LITERAL&&a->v->tag==SYM&&(n=PPa(parser,a,T_NAME)))R n;
+  elif(a->tag==N_LITERAL&&a->v->tag==SYM&&isunb(parser->st,a->v->val.symbol)&&(n=PPa(parser,a,T_NAME)))R n;
   elif(a->tag==N_LITERAL&&a->v->tag==ARRAY&&Cap(a->v->val.array)&&(n=PPa(parser,a,T_QUOTE)))R n;R a;}
 Nt*PPnoun(Pt*parser,B flat){Nt*a=flat?PPatom(parser):_PPnoun(parser);
   Tkt*tok;

+ 16 - 0
readme.md

@@ -66,6 +66,22 @@ W 1
 r 1
 d 1
 ! 1
+    *it@<:{."it / get most frequent
+l 3
+```
+
+## Make multiplication table
+```
+    *\.;.!.9
+1  2  3  4  5  6  7  8  9
+2  4  6  8 10 12 14 16 18
+3  6  9 12 15 18 21 24 27
+4  8 12 16 20 24 28 32 36
+5 10 15 20 25 30 35 40 45
+6 12 18 24 30 36 42 48 54
+7 14 21 28 35 42 49 56 63
+8 16 24 32 40 48 56 64 72
+9 18 27 36 45 54 63 72 81
 ```
 
 # Quick reference (also available in the interpreter itself)