Vocabulary/eqco

From J Wiki
Jump to navigation Jump to search

>> <<   Back to: Vocabulary Thru to: Dictionary

=: Is (Global) Other

Attaches a value to a name to yield a definition.

This is called assignment.

   myname =: 99     NB. defines: myname to be a noun: 99

   myname
99
   myname + 1
100

Unlike Is (Local) (=.), the definition will not go away when the "process" executing the assignment terminates.

This is called public assignment.

"Process" here means either executing an explicitly defined verb, or loading a J script.

The value assigned need not be a noun. It can also be a verb

   sum =: +/

   type 'sum'
+----+
|verb|
+----+

   sum 1 10 20.1
31.1

Or it can be a modifier (i.e. an adverb or a conjunction)

   tabulated =: /
   atop =: @

   type 'tabulated' ; 'atop'
+------+-----------+
|adverb|conjunction|
+------+-----------+

   MultiplicationTable =: * tabulated

   ] z =: 1 + i.6
1 2 3 4 5 6

   z MultiplicationTable z
1  2  3  4  5  6
2  4  6  8 10 12
3  6  9 12 15 18
4  8 12 16 20 24
5 10 15 20 25 30
6 12 18 24 30 36

You can place other constructs besides a bare name to the left of =:

   'a b c' =: 1 10 20.1
   a ; b ; c
+-+--+----+
|1|10|20.1|
+-+--+----+

   z =: 'd e f'
   (z) =: 1 10 20.1
   d ; e ; f
+-+--+----+
|1|10|20.1|
+-+--+----+

Common uses

Used to create nouns, adverbs, conjunctions and verbs which persist until you deliberately erase them.

Nouns, adverbs, conjunctions and verbs are the building-blocks of an application.


More Information

See Private and Public Assignment

Important.png Find time to study Private and Public Assignment carefully. (It describes and explains all uses of =. and =:)


CategoryVoc CategoryVocAssign CategoryVocValue CategoryVocVariable