I've been rewriting some of my APL tools in J. I wrote a Conjunction to
provide keyword in context. Its arguments are:
[x=. defaults to Width]
m=. 'look'
v=. FindFunction
y=. 'text to look in'

While writing updates to my tools, I decided to provide a constant function
that returned where two recent scripts first changed. I was suprised that
this version (highly simplified) got a value error.

Foo=: 3 : 0
f=. 4 : '123'
(y Context f old), y Context f new
)

Foo''
|value error: f
| ,.<"1((m v y)+/i:x){(x+#y){.y Replace LF;20{a.

Either making f global, or including (4 : '123') inline fixed the problem.
But I was curious why things didn't work as I would have expected. I had
assumed that verbs would be passed by definition and local vs global
wouldn't matter just as with nouns.

After a bit of testing I've confirmed that passing the local function as v
works. Was this known?

Goo=: 3 : 0
v=. 4 : '123'
(y Context v old), y Context v new
)

Paul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to