문제

Usually, I will use the :: primitive thus:

SomeVariable"_ :: ] DefaultValue

I'm looking for a way to wrap that ugly SOB. I'm trying to reason it. Normally, it would be with a tacit definition. This, for example:

default =: 13 : 'x"_ :: ] y'

fails miserably. Because, of course, in this context:

SomeVariable default DefaultValue

if SomeVariable doesn't exist, J will throw a valence error.

So, how can you wrap ::?

도움이 되었습니까?

해결책

You can indeed wrap :: but if you want to give it a verb argument, you need to deal with the syntactic issues.

For example, you can use an adverb:

fault=:1 :0
  u"_ :: ]
)

Or you could convert the verb you are manipulating into a gerund and pass that in (but that would be ugly, so I do not think you want that).

다른 팁

I use,

ORdef_z_ =: ".@[^:(_1< 4!:0@<@[)

 'asd' ORdef 3  NB. asd not assigned, returns right.
3
 asd =. 'asd' ORdef 3
asd=.'asd' ORdef 22  NB. will return 3 due to previous assignment
asd

3

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top