Git Product home page Git Product logo

i's People

Contributors

chrispsn avatar hoosieree avatar ktye avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

i's Issues

angle function

Hello,
I am trying to define a phase matrix, dependent by a parameter.
I defined this function:

P:{t:angle[1;x];(1 0;0 t)}

but if I run P 45, I receive this error:

P:{t:angle[1;x];(1 0;0 t)}
                       ^

even if I do not use the temp var, by defining:

P:{(1 0;0 angle[1;x])}

I receive another error:

P:{(1 0;0 angle[1;x])}
              ^

Do you have any idea why that is?

thanks,
Fausto

-n_ n# reuse

ndrop(-1, x) calls ntake which does not reuse memory on rc1.

e.g.

	s := sz(t)
	if I32(yp-4) == 1 && bucket(s*nn(y)) == bucket(s*n) && t < Lt {
		SetI32(yp-12, n)
		return y
	}

clang build : weird output

Hello,
I built k using the standard clang compiler available under MacOS Ventura.

Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.4.0

and I got no errors during the build phase.
But, in some case, I get some weird ascii chars output on the screen and not the proper output.

For example, running: ./k q.k t2.k (where q.k is available -not the latest version at the moment, but it's not relevant for this error- at https://gist.github.com/TheFausap/1e16bee4b1f2e5224a408e87b1014083)

and t2.k is basically:

K00:ts[K0;K0]
A:ts[K00;K00]
B:ts[K00;K00] 

if I want to print the state K00: and it should be |00> in standard notation, I have instead on the screen:

ktye/k
 K00
`ket|1 0 0 0
 pst K00
(1;"|�>")

if I am using the same files, but the binary is compiled using GCC under Linux (RockyLinux 9.1) I have the correct result.

ktye/k
 K00
`ket|1 0 0 0
 pst K00
(1;"|00>")

Is this expected with clang?

regards,
Fausto

Swapped fields in Decker fonts.deck?

I had an issue importing the fonts into the font-editor. The fields for "space" and "char width" seem to be swapped. f10x20, for example has a max font width of 10, a char width of 1 and a space between characters of 10. This works when just using the font, but (if I understand it correctly) the editor expects the opposite, ie char width of 10 (on each char) and a (global) space between characters of 1.

c/x86

e.g. modified indexed assign

#include<stdint.h>
void f(int32_t *x, int32_t y, int32_t z) { x[y]+=z; }

// f vs g

int32_t *I;
#define    I32(x)   I[(x)>>2]
#define SetI32(x,y) I[(x)>>2]=(y)
void g(uint64_t x, int32_t y, int32_t z) {
        SetI32(((int32_t)(x)+(4*y)),(I32(((int32_t)(x)+(4*y)))+z));
}

with -O3

f:
        movsx   rsi, esi
        add     DWORD PTR [rdi+rsi*4], edx
        ret
g:
        lea     eax, [rdi+rsi*4]
        mov     ecx, edx
        mov     rdx, QWORD PTR I[rip]
        sar     eax, 2
        cdqe
        add     DWORD PTR [rdx+rax*4], ecx
        ret
I:
        .zero   8

pack data section

currently the data section is (char-classes + z.k + ..):

1856 zz (uncompressed)
1143 zz.gz
1150 zz.zst (zstd -19)
1574 zz.lz4 (lz4  -12)

adding uncompressor for lz4 block is:

func u8(x int32) int32 { return I8(x) & 0xff }
func lz(p, e, d int32) int32 { //src-start, src-end, dst
	for {
		t := u8(p)
		p++
		l := t >> 4 //literal length
		if l == 15 {
			for {
				l += u8(p)
				p++
				if u8(p-1) != 255 {
					break
				}
			}
		}
		Memorycopy(d, p, l)
		p += l
		d += l
		if p >= e {
			return d
		}
		o := u8(p) | u8(p+1)<<8 //offset
		p += 2
		l = 4 + t&15 //match length
		if l == 19 {
			for {
				l += u8(p)
				p++
				if u8(p-1) != 255 {
					break
				}
			}
		}
		t = d + l
		for d < t {
			SetI8(d, u8(d-o))
			d += 1
			continue
		}
	}
	return 0
}

this costs 244 bytes.
but compression saves only 1856-1574-19 = 301 bytes.

test code:

func TestZ(t *testing.T) { // write zz (uncompressed)
	newtest()
	os.WriteFile("zz", Bytes[132:280+1708], 0744)
	reset()
}
func TestLz(t *testing.T) {
	z, err := os.ReadFile("zz.lz12")
	if err != nil {
		t.Fatal(err)
	}
	z = z[11:]
	z = z[:len(z)-8] // strip lz4 frame wrapper
	var orig []byte
	newtest()
	orig = append(orig, Bytes[132:280+1708]...)
	reset()
	Bytes = make([]byte, 8192)
	p, d := int32(132), int32(2048)
	copy(Bytes[p:], z)
	e := p + int32(len(z))
	r := lz(p, e, d)
	if string(orig) != string(Bytes[d:r]) {
		t.Fatal("lz4 mismatch")
	}
}

wb leb128

/in                   leb128
t:(0x5e0a000000000000;0xde14                 /2654
   0xffffff7f00000000;0xffffffff07           /2147483647
   0x000000000000e03f;0x80808080808080f03f   /4602678819172646912
   0x010000000000f87f;0x81808080808080fcff00 /9221120237041090561
   0x000000000000f07f;0x80808080808080f8ff00 /9218868437227405312
   0xffffffffffffffff;0x7f                   /-1                 (false)
   0x00f0ffffffffffff;0x8060                 /-4096
   0x000000000000f0ff;0x8080808080808078     /-4503599627370496
   0xffffffff000000ff;0xffffffff8f8080807f)  /-72057589742960641 (false)

leb8:{r:!0;B:1v:,/+(8#2)\\256/256+|x;while[B&(8<#v)&+/v;b:-7#v;s:*b;v:-7_v;r,:$[((0~&/v)|0x00~s)&(+/v)|s;1;B:0],b];_2//'-8^r}

g:leb8't i:2*!2\#t
e:t 1+i
 \g~'e

power of complex numbers

I was trying to get an integer power of a complex number and I created a function:

pN:{t:y#x;$[y=0;1a;*/t]}

using it in this function (it generates a matrix representing a quantum Fourier transform of log2(x) qubits):

QFT:{(1%%x)*(pN[om x]''((!x)*\:!x))}

where om function is:

om:{angle[1;360%x]}

Can some rounding be applied for the angle part?
For example, the matrix for 3 qubits (QFT 8) is:

0.353553a 0.353553a 0.353553a 0.353553a 0.353553a 0.353553a 0.353553..
0.353553a 0.353553a44.999999 0.353553a89.999999 0.353553a134.999999 ..
0.353553a 0.353553a89.999999 0.353553a179.999999 0.353553a270 0.3535..
0.353553a 0.353553a134.999999 0.353553a270 0.353553a44.999999 0.3535..
0.353553a 0.353553a179.999999 0.353553a359.999999 0.353553a179.99999..
0.353553a 0.353553a224.999999 0.353553a89.999999 0.353553a314.999999..
0.353553a 0.353553a270 0.353553a179.999999 0.353553a89.999999 0.3535..
0.353553a 0.353553a315 0.353553a269.999999 0.353553a224.999999 0.353..

thanks
Fausto

mod

3/-3+!7
0 -2 -1 0 1 2 0

should be
0 1 2 0 1 2 0

undefined: mku

when trying to build k- with go version go1.13.1 linux/amd64.
./a.go:11:15: undefined: mku

Enl

maybe simplify as uf(l1(x))

arity of derived

derived functions don't know their arity.
that means, projections for {x;y;z}/ need to be explicit

l,d

l:(1;2 3) 
d:`a`b`c!(4;5 6;7.)
l,d

k+ doesn't exit on Ctrl+D

When trying to exit k+ with Ctrl+D (rather than Ctrl+C), k+ outputs spaces forever rather than exiting.

encode

256 256\3 /0 3 /is 3
3 4\128 /2 0

odometer

could be much smaller:

odo:{x\\!*/x} /coltim

apl360

Adam:

Seems that pretty much every function is buggy!

  • 1=2 SYNTAX ERROR fixed
  • !3
  • ''⍴1 2 3
  • ~2 should domain error but doesn't.
  • ⍴⍳0 gives ⍳0 instead of ,0
  • ?n doesn't fail on negative numbers
  • 3⍺10 fails, and ditto ⍵ prefix/suffix vector?
  • 5↑2 1
  • ⍴10↓2 5
  • ''>5
  • I can assign to a¯3 and assignment seems to echo the assigned result.
  • ¯8*÷3 gives 0n instead of ¯2
  • Input. a←⎕ fails.
  • ⌈/⍳0 seems to give ⍳0 instead of the smallest representable float.
  • ⊤ seems to not work properly on non-scalars.
  • 0÷0 gives 0n instead of 1

definitely not a proper \360 playground.

rewrite token/parse in k

token&parse costs roughly 4300 bytes.
can we rewrite it shorter in k?

token/parse cannot be written in k because it loops.
but we could parse the parser and embed the instructions.

instruction embedding could be any of:

  • define a bytecode that can represent the instructions & implement a decoder
  • serialize the instruction list, compress it with lz4 & implement lz4 decompress

whatever, the result must be shorter than 4k of spacious wasm bytes.

Use in computer games

Hi, thanks for creating this!

I have decided to use a small fork of ktye/k in a computer game project.
My fork is here: https://gitlab.com/talas777/spesh

I only plan to use the C-version and I used the LGPLv3+ license (my favorite).

Please let me know if there is some way I can credit you or give attribution.
Perhaps a link to your project?
I added "Copyright (c) 2022,2023 ktye", hope that wasn't too wrong?

Thanks again!

(k!t)0

d:`b!`a!+`a`b!(1 2;3 4)
*d /fails

same as:

v:.d
v 0 /fails

or

k:`a!+`a`b!(1 2;3 4)
k 0 /fails

wa.k tail calls

wasm/tco could be:

-waret:{("\n"/:y),"\nreturn"}
+waret:{$[(`tail':opts)&(T 1+x)':`cal`cli;   "\n"/:|(,"return_",*y),1_y:|"\n"\:*y   ;("\n"/:y),"\nreturn"]}

todo: this generates some return_nop

triadic take

coltim: triadic take where the third argument specifies the fill. if the fill can be a list (matching the current "overtake" behavior) I think the variations could all be handled (cycling, using 0's, using nulls)

remove digraphs

             now         new

each         +'x        same
over         +/x        same
scan         +\x        same

each2       x+'y        same
over-init   x+/y       +/x,y
scan-init   x+\y       +\x,y

each-n    F'[..]        same (n>2)
over-n    F/[..]        same (n>2)
scan-n    F\[..]        same (n>2)

each-prior  -':x         ???
fixedpoint  f/:x         f/x (monadic)
fixedscan   f\:x         f\x
transition 0{L[x;y]}\x L\0,x

each-left  x+\:y        x+\y
each-right x+/:y        x+/y

join        x/:y         c/y (chars only)
split       x\:y         c\y (chars only)
decode      x//y         n/y (numbers)
encode      x\\y         n\y (numbers)

div          x\y         y%x (int remains)
mod          x/y         x!y (i-atom only)
ndo        f n/x        retire

bin          x'y        same
lin        x y'z        {..}
 in         x':y        a?v (remove shuffle/deal)

deal/shuffle n?v      v(n?#v)


each-prior: maybe
sqrt          %x      sqrt x (verb-code)
rotate-fill  n/a          %x  %1 2 3 /0 1 2
prior       -':x        x-%x

or define prior:{[f;x;x0]f[x;-1_x0,x]}

sin 0n 0w

wasm f64.convert_i64_u fails in chrome for 0n 0w -0w
math.go:cosin_:
j := uint64(x * 1.2732395447351628)

,\1 2 3

,\1 2 3 could be (!0),\1 2 3
(,1;1 2;1 2 3)

(),\1 2 3 is broken just as (),/1 2 3 (no unify)

`l@ empty table

`k t is ok, but `l t fails if t is empty.

 k:0#`
 v:()
 t:+k!v
 t
T:{[x;k]$[`L?@'.x;,k x;(,*x),(,(#*x)#"-"),1
            ^
   t
+(0#`)!()

" /"

token: this is not a comment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.