To: personal-kdbplus@googlegroups.com
X-Mailer: Apple Mail (2.1084)
>>> but disappointed that i can’t write something like this (in k):
>>>
>>> (0 4_“mov add “)X”,”:/'0 3_'XX"e",‘0 2_“axcxdxbxbpsidi”
>>
>> .q.X[.q.cut[4]“mov add “]@”,”/:‘3 =
.q.cut’.q.XX"e",’.q.cut[2]“axcxdxbxbpsidi”
>
> i was disappointed that i can’t define X as an infix operator in k
> (ie. use X without .q.X qualification)
yes, unfortunately k has neither of the blessed namespace behaviors =
(resolving and infix)
>> incidentally to me the most natural solution to the original question =
is
>>
>> q)r:enlist each(“eax”;“ecx”;“edx”)
>> q)o:enlist each(“mov”;“add”)
>> q)o cross r cross r
>> “mov” “eax” “eax”
>> “mov” “eax” “ecx”
>
> yes, this is the essence of the expression. i have the cuts on input
> data so i can show my input and intention in one line - maybe 3 lines
> would have been better. what would arthur do?
i don’t know, i might do
q){x," “,y,”,“,z}.'{(cross)over(enlist each x;y;y:enlist each =
y)}[(“mov”;“add”);“e”,'2 cut"axcxdxbxbpsidi”]
k){x," “,y,”,",z}.'{.q.cross/(,:'x;y;y:,:'y)}[(“mov”;“add”);“e”,'0N =
2#“axcxdxbxbpsidi”]
if i wanted to keep it on one line
i might prefer something like
q){x," “,y,”,“,z}.'string{(cross)over(x;y;y)}[`mov`add;`$“e”,'2 =
cut"axcxdxbxbpsidi”]
k){x," “,y,”,",z}.'${.q.cross/(x;y;y)}[`mov`add;`$“e”,'0N =
2#“axcxdxbxbpsidi”]
though, since conceptually the opcodes and registers are enums =
(independent of how you generate them)
(my best guess at arthur’s style might be something like
k){" “/:',/(,:‘0N 3#x),/::,:’”,"/:'y:,/y,/::y:,:'y}[“movadd”]“e”,'0N =
2#“axcxdxbxbpsidi”
taking it as a string-manipulation problem, or
k){,/'${,/z,/::y,'x}/[y;", =
";(y;x)]}[mov
add]$"e",'$
axcx
dxbx
bpsi
di
as a list-manipulation problem)=