kevinlawler / kona

Open-source implementation of the K programming language
ISC License
1.36k stars 138 forks source link

Burrows Wheeler Transform #240

Closed tavmem closed 10 years ago

tavmem commented 10 years ago

Although the simplified problem instance documented as issue 239 was resolved, the BWT app still does not work properly:

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!" (;;;;;;;;;;;;;;;;"\000")

twb e: bwt "dilute dilute ok!" "dilute dilute ok!"

You only get a correct result by making the "bwt result" a global.

silentbicycle commented 10 years ago

I noticed that. Is that a bug, or am I misunderstanding how scope works in kona?

Scott

On Tue, Mar 11, 2014 at 7:07 PM, Tom Szczesny notifications@github.comwrote:

Although the simplified problem instance documented as issue 239 was resolved, the BWT app still does not work properly:

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!" (;;;;;;;;;;;;;;;;"\000")

e:bwt "dilute dilute ok!" twb bwt "dilute dilute ok!" "dilute dilute ok!"

You only get a correct result by making the "bwt result" a global.

Reply to this email directly or view it on GitHubhttps://github.com/kevinlawler/kona/issues/240 .

tavmem commented 10 years ago

Scope should not work like that in Kona. There is at least one bug there, and there may be several that need to be discovered and fixed before BWT works properly.

tavmem commented 10 years ago

As an interim solution, this method creates an extra local variable m, but eliminates the global e. bwt:{[s],//1#'|:'{x@<x}(!#a)!\: a:"\0",s} // the BWT s:{x@<x} twb:{[e]1_*s m:(-1+#e){[x]e,'s x}/e} // undo the BWT twb bwt "dilute dilute ok!" "dilute dilute ok!"

tavmem commented 10 years ago

Epilogue: it works now (no extra globals, no extra locals): 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!" "dilute dilute ok!"