How to list the code of a verb in J

南楼画角 提交于 2019-12-30 06:54:25

问题


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

回答1:


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
)


来源:https://stackoverflow.com/questions/12181127/how-to-list-the-code-of-a-verb-in-j

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!