How to list the code of a verb in J
Asked Answered
A

1

5

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
Anarchism answered 29/8, 2012 at 15:11 Comment(0)
B
9

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
)
Berberine answered 29/8, 2012 at 15:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.