Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list the code of a verb in J

Tags:

j

In the console, typing a single verb without parameters will print its content:

   tolower

3 : 0
x=. I. 26 > n=. ((65+i.26){a.) i. t=. ,y
($y) $ ((x{n) { (97+i.26){a.) x}t
)

That's nice for development, but unexploitable during execution. Is there a way to do that dynamically? Is there a verb that can return the contents of another verb?

For example:

showverb 'tolower'

or

showverb tolower
like image 781
MPelletier Avatar asked Aug 29 '12 15:08

MPelletier


1 Answers

You can use its representation. For example the boxed representation (5!:2) of tolower is:

   (5!:2) <'tolower'
┌─┬─┬────────────────────────────────────────┐
│3│:│x=. I. 26 > n=. ((65+i.26){a.) i. t=. ,y│
│ │ │($y) $ ((x{n) { (97+i.26){a.) x}t       │
└─┴─┴────────────────────────────────────────┘

its linear (5!:5) is:

   (5!:5) <'tolower'
3 : 0
x=. I. 26 > n=. ((65+i.26){a.) i. t=. ,y
($y) $ ((x{n) { (97+i.26){a.) x}t
)
like image 116
Eelvex Avatar answered Oct 01 '22 04:10

Eelvex