Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Rich H.J for C programmers.2006.pdf
Скачиваний:
19
Добавлен:
23.08.2013
Размер:
1.79 Mб
Скачать

+ onprefixes 1 2 3 4 1 3 6 10

A conjunction with one operand also defines an adverb. A conjunction needs two operands, but if you supply one, the combination is treated as an adverb that attaches its operand to the empty side of the conjunction. For example, (2&) is an adverb, and

+ (2&) is equivalent to 2&+ . For another example, the J startup scripts define each =: &.>

so that

>: each 1 2 3 is equivalent to

>:&.> 1 2 3 +-+-+-+ |2|3|4| +-+-+-+

Referring To a Noun In a Tacit Verb

Suppose you want a verb v that returns the current value of the noun n (maybe it's a button handler). Suppose you want v to be tacitly defined. How would you do it? You can't use

v =: n

because that would use the value of n at the time v is defined (in fact, v would be a noun), and you want the value of n when v is executed. Use this trick:

v =: ".@:('n'"_)

When this is executed, the operand is ignored and replaced by the string 'n', which is then executed by ". to produce the value of the noun n .

235