Closed spreadLink closed 6 years ago
Yes, it's definitely a bug. Thanks!!! In k2.8:
$ rlwrap -n ~/k2.8/k
K 2.8 2000-10-10 Copyright (C) 1993-2000 Kx Systems
Evaluation. Not for commercial use.
\ for help. \\ to exit.
id:2 2 # 1 1 1 0
id
(1 1
1 0)
5 {id _mul x}/ id
(13 8
8 5)
{5 {id _mul x}/ id}[]
(13 8
8 5)
{[n] n {id _mul x}/ id}[5]
(13 8
8 5)
This is interesting. In kona:
$ rlwrap -n ~/kona/k
kona \ for help. \\ to exit.
id:2 2 # 1 1 1 0
{[n] n {id _mul x}/ id}[5]
(13 8
8 5)
\\
but:
$ rlwrap -n ~/kona/k
kona \ for help. \\ to exit.
id:2 2 # 1 1 1 0
5 {id _mul x}/ id
(13 8
8 5)
{[n] n {id _mul x}/ id}[5]
type error
x _dot\:y
^
The above is a regression. In the commit 068fc66eb33e8b577965c2b9ba1fa5fa0ae8aa9f of Mar 11, 2014:
$ rlwrap -n ./k
K Console - Enter \ for help
id:2 2 # 1 1 1 0
(1 1
1 0)
5 {id _mul x}/ id
(13 8
8 5)
{[n] n {id _mul x}/ id}[5]
(13 8
8 5)
It no longer works beginning with the commit b887d9005c7de84e42d5c219afd10d8d77ae9ff5 of Mar 13, 2014.
Just as an FYI: The commit that causes the problem (above) was made to fix a problem in the Burrows Wheeler Transform script:
$ cat bwt.k
bwt:{[s],//1#'|:'{x@<x}(!#a)!\: a:"\0",s} // the BWT
s:{x@<x}
twb:{[e]1_*s(-1+#e){[x]e,'s x}/e} // undo the BWT
twb bwt "dilute dilute ok!"
$
Executing the script using the commit of Mar 11, 2014 you get:
$ rlwrap -n ./k ~/nsl/bwt.k
K Console - Enter \ for help
{[s],//1#'|:'{x@<x}(!#a)!\: a:"\0",s}
{x@<x}
{[e]1_*s(-1+#e){[x]e,'s x}/e}
(;;;;;;;;;;;;;;;;"\000")
Using the commit of Mar 13, 2014 you get the correct result:
$ rlwrap -n ./k ~/nsl/bwt.k
K Console - Enter \ for help
{[s],//1#'|:'{x@<x}(!#a)!\: a:"\0",s}
{x@<x}
{[e]1_*s(-1+#e){[x]e,'s x}/e}
"dilute dilute ok!"
That's quite interesting. So it specifically overrides the argument capture?
The commit of Mar 13, 2014 was to address a scoping problem described in issues 239 and 240 which was identified by @silentbicycle in his implementation of the Burrows Wheeler Transform. The issue that you identified became a regression caused by fixing the scope problem, but I think it can be fixed in a manner that preserves the proper functioning of the BWT. Still working on it.
Oh i see. Thank you very much then :smile:
I'm not sure if this occurs due to how the evaluation rules work, but I'm p sure it is indeed a bug. Specifically, the over form of "n m/ x", where n is an integer, m a monadic function and x some starting argument, should apply m to x n times. And it does, unless n is supplied as an argument in a function (please see the screenshot for when specifically the error occurs). (id here is "2 2 # 1 1 1 0", the function as a whole is supposed to be the fibonacci Q matrix thingy)