ext.diff 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. diff --color -ur ktye/i/+/sqlite/sqlite.c sqlite/sqlite.c
  2. --- ktye/i/+/sqlite/sqlite.c 2024-05-26 20:39:33
  3. +++ sqlite/sqlite.c 2024-06-06 14:16:18
  4. @@ -49,13 +49,13 @@
  5. default:;
  6. int nb = sqlite3_column_bytes(res, i);
  7. K c = KC((char *)sqlite3_column_blob(res, i), (size_t)nb);
  8. - l[i] = Kx(",", l[i], Kx(",", c)); // l,,c
  9. + l[i] = Kx(",", ref(l[i]), Kx(",:", c)); // l,,c
  10. }
  11. }
  12. row0 = 0;
  13. }
  14. - K t = Kx("+", Kx("!", keys, KL(l, cols)));
  15. + K t = Kx("+:", Kx("!", keys, KL(l, cols)));
  16. free(l);
  17. return t;
  18. @@ -67,10 +67,10 @@
  19. static void addTable(sqlite3 *db, K name, K t){ // add k table to sqlite db (https://qastack.com.de/programming/1711631/improve-insert-per-second-performance-of-sqlite)
  20. K l2[2]; LK(l2,t);
  21. - K p = Kx(",", KC0("INSERT INTO "), Kx("$", ref(name))); // p:"insert into tname values(?,?,..)"
  22. + K p = Kx(",", KC0("INSERT INTO "), Kx("$:", ref(name))); // p:"insert into tname values(?,?,..)"
  23. p = Kx(",", p, KC0(" VALUES("));
  24. - K q = Kx(",", KC0("CREATE TABLE "), Kx("$", name)); // q:"create table tname(col1 type1, col2 type2, ...)"
  25. + K q = Kx(",", KC0("CREATE TABLE "), Kx("$:", name)); // q:"create table tname(col1 type1, col2 type2, ...)"
  26. q = Kx(",", q, KC0("("));
  27. size_t nc = NK(l2[0]);
  28. @@ -79,7 +79,7 @@
  29. for(int i=0;i<nc;i++){
  30. p = Kx(",", p, Kc('?'));
  31. - q = Kx(",", q, Kx("$", Kx("@", ref(l2[0]), Ki(i))));
  32. + q = Kx(",", q, Kx("$:", Kx("@", ref(l2[0]), Ki(i))));
  33. K ty;
  34. switch(TK(cols[i])){
  35. case 'I': ty = KC0(" INTEGER"); break;
  36. @@ -113,7 +113,7 @@
  37. case 'I': sqlite3_bind_int(stmt, 1+i, iK(v)); break;
  38. case 'F': sqlite3_bind_double(stmt, 1+i, fK(v)); break;
  39. case 'S':;
  40. - K s = Kx("$", v);
  41. + K s = Kx("$:", v);
  42. sqlite3_bind_text(stmt, 1+i, dK(s), NK(s), NULL);
  43. unref(s);
  44. break;
  45. @@ -176,7 +176,7 @@
  46. size_t n= NK(names);
  47. K *l = malloc(sizeof(K)*n);
  48. K q = KC("select * from ", 14);
  49. - for(int i=0;i<n;i++) l[i] = getTable(db, Kx(",", ref(q), Kx("$", Kx("@", ref(names), Ki(i))))); // q,$names@i
  50. + for(int i=0;i<n;i++) l[i] = getTable(db, Kx(",", ref(q), Kx("$:", Kx("@", ref(names), Ki(i))))); // q,$names@i
  51. K r = Kx("!", names, KL(l, n));
  52. unref(q);
  53. free(l);
  54. @@ -232,9 +232,9 @@
  55. return r;
  56. }
  57. +__attribute__((constructor)) void loadsql();
  58. void loadsql() {
  59. - exit(-1);
  60. KR("sqlite", (void*)sqlite, 1);
  61. KR("sqlq", (void*)sqlq, 2);
  62. }
  63. diff --color -ur ktye/i/+/sqlite/sqlite.k sqlite/sqlite.k
  64. --- ktye/i/+/sqlite/sqlite.k 2024-01-11 10:40:45
  65. +++ sqlite/sqlite.k 2024-06-06 14:05:07
  66. @@ -1,7 +1,9 @@
  67. +`"libsqll.dylib"2:(`loadsql;1);
  68. +
  69. t:+`a`b`c`d!(1 2;3 4.;`abc`def;("alpha";"beta"))
  70. c:sqlite `t!,t
  71. -s:sqlq[c;"select sum(b) as M from t"]
  72. +/s:sqlq[c;"select sum(b) as M from t"]
  73. T:sqlite c
  74. -
  75. - \"query ",$$[7.~*s`M;`ok;`fail]
  76. - \"roundtrip ",$$[T~`t!,t;`ok;`fail]
  77. +/
  78. + "query ",$$[7.~*s`M;`ok;`fail]
  79. + "roundtrip ",$$[T~`t!,t;`ok;`fail]
  80. diff --color -ur ktye/i/+/mat/mat.c mat/mat.c
  81. --- ktye/i/+/mat/mat.c 2024-01-11 10:40:45
  82. +++ mat/mat.c 2024-06-06 12:50:50
  83. @@ -1,6 +1,6 @@
  84. #include<stdlib.h>
  85. #include<string.h>
  86. -#include"../k.h"
  87. +#include"k.h"
  88. // dgesv solve linear system (real)
  89. // x: L columns (input matrix)
  90. @@ -351,6 +351,8 @@
  91. K dgesvD(K x){ return svd(x, 1, 'S'); }
  92. K zgesvd(K x){ return svd(x, 2, 'N'); }
  93. K zgesvD(K x){ return svd(x, 2, 'S'); }
  94. +
  95. +__attribute__((constructor)) void loadmat();
  96. void loadmat(){
  97. KR("dgesv", (void*)dgesv, 2);
  98. diff --color -ur ktye/i/+/mat/mat.k mat/mat.k
  99. --- ktye/i/+/mat/mat.k 2024-01-11 10:40:45
  100. +++ mat/mat.k 2024-06-06 12:59:19
  101. @@ -1,9 +1,10 @@
  102. /lapack tests
  103. +`"libmat.dylib" 2:(`loadmat;1);
  104. -test:{x;y;$[x<y;"ok ";"fail "]," "/:$(x;"<";y)}
  105. -
  106. -FZ:{`f@'x} /ktye convert matrix z to f
  107. -fz:{`f@x } / vector
  108. +test:{x;y;$[x<y;"ok ";"fail "]," "/$(x;"<";y)}
  109. +abs:{x|-x}
  110. +FZ:{`f$'x} /ktye convert matrix z to f
  111. +fz:{`f$x } / vector
  112. /dgesv
  113. A:+(6.80 -6.05 -0.45 8.32 -9.67
  114. diff --color -ur ktye/i/+/draw/align.k draw/align.k
  115. --- ktye/i/+/draw/align.k 2024-01-11 10:40:45
  116. +++ draw/align.k 2024-06-06 14:37:56
  117. @@ -1,3 +1,5 @@
  118. +`"libdraw.dylib"2:(`loaddrw;1);
  119. +`"libray.dylib"2:(`loadray;1);
  120. t:{(`color;255; `Circle;x,4;`color;0;`text;(x;y;"Abcg",$y))}
  121. T:{(`color;255*256;`Circle;x,4;`color;0;`Text;(x;y;"Abcg",$y))}
  122. diff --color -ur ktye/i/+/draw/clip.k draw/clip.k
  123. --- ktye/i/+/draw/clip.k 2024-01-11 10:40:45
  124. +++ draw/clip.k 2024-06-06 14:37:52
  125. @@ -1,3 +1,6 @@
  126. +`"libdraw.dylib"2:(`loaddrw;1);
  127. +`"libray.dylib"2:(`loadray;1);
  128. +
  129. /canvas shows 3 (clipped) black circles
  130. /cairo 1.17.2 shows only 1
  131. diff --color -ur ktye/i/+/draw/draw.c draw/draw.c
  132. --- ktye/i/+/draw/draw.c 2024-01-11 10:40:45
  133. +++ draw/draw.c 2024-06-06 12:50:17
  134. @@ -1,7 +1,7 @@
  135. #include<stdlib.h>
  136. #include<string.h>
  137. #include<cairo.h>
  138. -#include"../k.h"
  139. +#include"k.h"
  140. #include<stdio.h>
  141. @@ -290,6 +290,7 @@
  142. static void rgb24(uint32_t *u, size_t n){ for(int i=0;i<n;i++) u[i] = ((u[i]&0xff)<<16) | ((u[i]&0xff0000)>>16) | u[i]&0xff00; }
  143. +__attribute__((constructor)) void loaddrw();
  144. void loaddrw(){
  145. drawcmds = Kx("`color`font`linewidth`rect`Rect`circle`Circle`clip`line`poly`Poly`text`Text");
  146. diff --color -ur ktye/i/+/draw/draw.k draw/draw.k
  147. --- ktye/i/+/draw/draw.k 2024-01-11 10:40:45
  148. +++ draw/draw.k 2024-06-06 14:32:52
  149. @@ -1,3 +1,5 @@
  150. +`"libdraw.dylib"2:(`loaddrw;1);
  151. +`"libray.dylib"2:(`loadray;1);
  152. d:(`color;123;`Rect;0 0 100 50)
  153. m:draw[d;100 50]
  154. diff --color -ur ktye/i/+/ray/ray.c ray/ray.c
  155. --- ktye/i/+/ray/ray.c 2024-01-11 10:40:45
  156. +++ ray/ray.c 2024-06-06 14:35:53
  157. @@ -18,7 +18,7 @@
  158. #include<string.h>
  159. #include"raylib.h"
  160. #include"rgestures.h"
  161. -#include"../k.h"
  162. +#include"k.h"
  163. K png(K); // ../img/img.c
  164. @@ -131,7 +131,9 @@
  165. }
  166. //show(50;10000#255) /red window 100x50
  167. -K show(K x){ Show(x, Ki(0), Ki(0)); }
  168. +K show(K x){ Show(x, Ki(0), Ki(0)); return Ki(0); }
  169. +
  170. +__attribute__((constructor)) void loadray();
  171. void loadray(){
  172. KR("show", (void*)show, 1); // show image from data or png