Skip to content

Instantly share code, notes, and snippets.

@adrian17 adrian17/whence.ijs
Last active Aug 29, 2015

Embed
What would you like to do?
whence for J
whence =: verb define
select. 4!:0 < y
case. _2 do. 'invalid name'
case. _1 do. 'name not defined'
case. 0;1;2;3 do.
index =. 4!:4 < y
select. * >: index
case. 0 do. 'name defined locally'
case. 1 do. > index { 4!:3''
end.
end.
)
whence ''
whence 'not_defined'
whence 'in_interpreter' NB. define this in interpreter first
whence 'whence'
err1 =. 'invalid name'"_
err2 =. 'name not defined'"_
err3 =. 'name defined locally'"_
find_name =. [: > (4!:3'') {~ ]
NB. helper; I didn't want to make everything one line
whence2 =. [: err3`find_name@.(* @ >:) [: 4!:4 <
whence =: err1`err2`whence2@.([: >: [: * [: >: [: 4!:0 <)
whence ''
whence 'not_defined'
whence 'in_interpreter' NB. define this in interpreter first
whence 'whence'
whence =: verb define
if. _2 = 4!:0 < y do.
'invalid name'
return.
elseif. _1 = 4!:0 < y do.
'name not defined'
return.
end.
index =. 4!:4 < y
if. _1 = index do.
'name defined locally'
return.
end.
> index { 4!:3''
)
whence ''
whence 'not_defined'
whence 'in_interpreter' NB. define this in interpreter first
whence 'whence'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.