123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- diff --color -ur ktye/i/+/sqlite/sqlite.c sqlite/sqlite.c
- --- ktye/i/+/sqlite/sqlite.c 2024-05-26 20:39:33
- +++ sqlite/sqlite.c 2024-06-06 14:16:18
- @@ -49,13 +49,13 @@
- default:;
- int nb = sqlite3_column_bytes(res, i);
- K c = KC((char *)sqlite3_column_blob(res, i), (size_t)nb);
- - l[i] = Kx(",", l[i], Kx(",", c)); // l,,c
- + l[i] = Kx(",", ref(l[i]), Kx(",:", c)); // l,,c
- }
- }
- row0 = 0;
- }
-
- - K t = Kx("+", Kx("!", keys, KL(l, cols)));
- + K t = Kx("+:", Kx("!", keys, KL(l, cols)));
- free(l);
-
- return t;
- @@ -67,10 +67,10 @@
- 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)
- K l2[2]; LK(l2,t);
-
- - K p = Kx(",", KC0("INSERT INTO "), Kx("$", ref(name))); // p:"insert into tname values(?,?,..)"
- + K p = Kx(",", KC0("INSERT INTO "), Kx("$:", ref(name))); // p:"insert into tname values(?,?,..)"
- p = Kx(",", p, KC0(" VALUES("));
-
- - K q = Kx(",", KC0("CREATE TABLE "), Kx("$", name)); // q:"create table tname(col1 type1, col2 type2, ...)"
- + K q = Kx(",", KC0("CREATE TABLE "), Kx("$:", name)); // q:"create table tname(col1 type1, col2 type2, ...)"
- q = Kx(",", q, KC0("("));
-
- size_t nc = NK(l2[0]);
- @@ -79,7 +79,7 @@
-
- for(int i=0;i<nc;i++){
- p = Kx(",", p, Kc('?'));
- - q = Kx(",", q, Kx("$", Kx("@", ref(l2[0]), Ki(i))));
- + q = Kx(",", q, Kx("$:", Kx("@", ref(l2[0]), Ki(i))));
- K ty;
- switch(TK(cols[i])){
- case 'I': ty = KC0(" INTEGER"); break;
- @@ -113,7 +113,7 @@
- case 'I': sqlite3_bind_int(stmt, 1+i, iK(v)); break;
- case 'F': sqlite3_bind_double(stmt, 1+i, fK(v)); break;
- case 'S':;
- - K s = Kx("$", v);
- + K s = Kx("$:", v);
- sqlite3_bind_text(stmt, 1+i, dK(s), NK(s), NULL);
- unref(s);
- break;
- @@ -176,7 +176,7 @@
- size_t n= NK(names);
- K *l = malloc(sizeof(K)*n);
- K q = KC("select * from ", 14);
- - for(int i=0;i<n;i++) l[i] = getTable(db, Kx(",", ref(q), Kx("$", Kx("@", ref(names), Ki(i))))); // q,$names@i
- + for(int i=0;i<n;i++) l[i] = getTable(db, Kx(",", ref(q), Kx("$:", Kx("@", ref(names), Ki(i))))); // q,$names@i
- K r = Kx("!", names, KL(l, n));
- unref(q);
- free(l);
- @@ -232,9 +232,9 @@
- return r;
- }
-
- +__attribute__((constructor)) void loadsql();
-
- void loadsql() {
- - exit(-1);
- KR("sqlite", (void*)sqlite, 1);
- KR("sqlq", (void*)sqlq, 2);
- }
- diff --color -ur ktye/i/+/sqlite/sqlite.k sqlite/sqlite.k
- --- ktye/i/+/sqlite/sqlite.k 2024-01-11 10:40:45
- +++ sqlite/sqlite.k 2024-06-06 14:05:07
- @@ -1,7 +1,9 @@
- +`"libsqll.dylib"2:(`loadsql;1);
- +
- t:+`a`b`c`d!(1 2;3 4.;`abc`def;("alpha";"beta"))
- c:sqlite `t!,t
- -s:sqlq[c;"select sum(b) as M from t"]
- +/s:sqlq[c;"select sum(b) as M from t"]
- T:sqlite c
- -
- - \"query ",$$[7.~*s`M;`ok;`fail]
- - \"roundtrip ",$$[T~`t!,t;`ok;`fail]
- +/
- + "query ",$$[7.~*s`M;`ok;`fail]
- + "roundtrip ",$$[T~`t!,t;`ok;`fail]
- diff --color -ur ktye/i/+/mat/mat.c mat/mat.c
- --- ktye/i/+/mat/mat.c 2024-01-11 10:40:45
- +++ mat/mat.c 2024-06-06 12:50:50
- @@ -1,6 +1,6 @@
- #include<stdlib.h>
- #include<string.h>
- -#include"../k.h"
- +#include"k.h"
-
- // dgesv solve linear system (real)
- // x: L columns (input matrix)
- @@ -351,6 +351,8 @@
- K dgesvD(K x){ return svd(x, 1, 'S'); }
- K zgesvd(K x){ return svd(x, 2, 'N'); }
- K zgesvD(K x){ return svd(x, 2, 'S'); }
- +
- +__attribute__((constructor)) void loadmat();
-
- void loadmat(){
- KR("dgesv", (void*)dgesv, 2);
- diff --color -ur ktye/i/+/mat/mat.k mat/mat.k
- --- ktye/i/+/mat/mat.k 2024-01-11 10:40:45
- +++ mat/mat.k 2024-06-06 12:59:19
- @@ -1,9 +1,10 @@
- /lapack tests
- +`"libmat.dylib" 2:(`loadmat;1);
-
- -test:{x;y;$[x<y;"ok ";"fail "]," "/:$(x;"<";y)}
- -
- -FZ:{`f@'x} /ktye convert matrix z to f
- -fz:{`f@x } / vector
- +test:{x;y;$[x<y;"ok ";"fail "]," "/$(x;"<";y)}
- +abs:{x|-x}
- +FZ:{`f$'x} /ktye convert matrix z to f
- +fz:{`f$x } / vector
-
- /dgesv
- A:+(6.80 -6.05 -0.45 8.32 -9.67
- diff --color -ur ktye/i/+/draw/align.k draw/align.k
- --- ktye/i/+/draw/align.k 2024-01-11 10:40:45
- +++ draw/align.k 2024-06-06 14:37:56
- @@ -1,3 +1,5 @@
- +`"libdraw.dylib"2:(`loaddrw;1);
- +`"libray.dylib"2:(`loadray;1);
-
- t:{(`color;255; `Circle;x,4;`color;0;`text;(x;y;"Abcg",$y))}
- T:{(`color;255*256;`Circle;x,4;`color;0;`Text;(x;y;"Abcg",$y))}
- diff --color -ur ktye/i/+/draw/clip.k draw/clip.k
- --- ktye/i/+/draw/clip.k 2024-01-11 10:40:45
- +++ draw/clip.k 2024-06-06 14:37:52
- @@ -1,3 +1,6 @@
- +`"libdraw.dylib"2:(`loaddrw;1);
- +`"libray.dylib"2:(`loadray;1);
- +
- /canvas shows 3 (clipped) black circles
- /cairo 1.17.2 shows only 1
-
- diff --color -ur ktye/i/+/draw/draw.c draw/draw.c
- --- ktye/i/+/draw/draw.c 2024-01-11 10:40:45
- +++ draw/draw.c 2024-06-06 12:50:17
- @@ -1,7 +1,7 @@
- #include<stdlib.h>
- #include<string.h>
- #include<cairo.h>
- -#include"../k.h"
- +#include"k.h"
-
- #include<stdio.h>
-
- @@ -290,6 +290,7 @@
- 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; }
-
-
- +__attribute__((constructor)) void loaddrw();
-
- void loaddrw(){
- drawcmds = Kx("`color`font`linewidth`rect`Rect`circle`Circle`clip`line`poly`Poly`text`Text");
- diff --color -ur ktye/i/+/draw/draw.k draw/draw.k
- --- ktye/i/+/draw/draw.k 2024-01-11 10:40:45
- +++ draw/draw.k 2024-06-06 14:32:52
- @@ -1,3 +1,5 @@
- +`"libdraw.dylib"2:(`loaddrw;1);
- +`"libray.dylib"2:(`loadray;1);
- d:(`color;123;`Rect;0 0 100 50)
- m:draw[d;100 50]
-
- diff --color -ur ktye/i/+/ray/ray.c ray/ray.c
- --- ktye/i/+/ray/ray.c 2024-01-11 10:40:45
- +++ ray/ray.c 2024-06-06 14:35:53
- @@ -18,7 +18,7 @@
- #include<string.h>
- #include"raylib.h"
- #include"rgestures.h"
- -#include"../k.h"
- +#include"k.h"
-
-
- K png(K); // ../img/img.c
- @@ -131,7 +131,9 @@
- }
-
- //show(50;10000#255) /red window 100x50
- -K show(K x){ Show(x, Ki(0), Ki(0)); }
- +K show(K x){ Show(x, Ki(0), Ki(0)); return Ki(0); }
- +
- +__attribute__((constructor)) void loadray();
-
- void loadray(){
- KR("show", (void*)show, 1); // show image from data or png
|