Logo notas.itmens

Quick Reference

Always start with

⎕IO ← 0 ⍝ optional!
]box on -s=min
]rows on

Caution: Indexing starts from 1 by default. You can change the index origin by setting ⎕IO←0.

Article Image
All ` becomes Right Alt in our case.
Symbols / functions)Monadic (variable \(v\))Dyadic (variable \(v\) and \(w\))
:Control statement and error handling:
:If / :ElseIf / :Else / :EndIf - :For / :EndFor - :While / :EndWhile - :Repeat / :Until - :Trap / :EndTrap
Inline conditional return:
   ⍵=2:⍺
If ⍵ is 2 then return ⍺
+Plus:
    +3
3
Plus:
    2 + 3
5
-0 minus:
    - 3
-3
Minus:
    2 - 3
¯1
×Direction (\(v/|v|\)):
    × 3 ¯2 2.1 ¯100
1 ¯1 1 ¯1
Times:
    3 1 4 × 1 2 3
3 2 12
÷Reciprocal (\(1/v\)):
    ÷ 1 2 0.2
1 0.5 5
Divide:
    1 2 3 ÷ 2 4 9
0.5 0.5 0.3333333333
|Absolute value:
    | ¯2 4 3
2 4 3
MOD ( v|w is \(w \mod v\)):
    2 | 9 8 7
1 0 1
*Exponential (\(e^v\)):
    * 3
20.08553692
Power (v * w is \(v^w\)):
    2 * 1 2 3
2 4 8
Natural Logarithm (\(\ln v\)):
    ⍟ 1 2.7
0 0.993251773
Logarithm (v ⍟ w is \(\log_v w\)):
    2.7 ⍟ 1 2.7 9
0 1 2.212152686
Round up (unconditionally up):
    ⌈ 2.1 3.4 3.5
3 4 4
Maximum (v ⌈ w is \(\max(v,w)\)):
    3 4 1 ⌈ 5 2 1
5 4 1
Round down (unconditionally down):
    ⌊ 2.1 3.4 3.5
2 3 3
Minimum (v ⌊ w is \(\min(v,w)\)):
    3 4 1 ⌊ 5 2 1
3 2 1
Index Generator; generates an \(n_1 \times n_2 \times … \times n_k\) “matrix”Index of (only returns the first occurence):
    'ABCDABCDEF' ⍳ 'ACF' 
1 3 10
Comment (to the right is ignored)N/A
/Reduce (Fold; reduces the dimensions of its argument):
    +/1 2 3 4 ⍝ equivalent to 1 + 2 + 3 + 4
10
Replicate:
    2 3/'AB'
AABBB
Statement (equivalent t newline characters in terms of execution):
      A←4 ⋄ A←A×3 ⋄ A÷2

(" and line breaks are equivalent in almost all cases. One difference is that when you trace through a function, you can only execute one line at a time, even if it has multiple statements separated by . Also, one-liner dfns, even if they have s, cannot be suspended or traced into – they will always execute completely and quit. If an error happens, the stack is cut back to their caller. This is actually useful, to prevent your program from stopping in a bad state.")
 
Shape (returns the shape):
    ⍵← 1 3 4 ⋄ ⍴⍵
3
Reshape:
    3 3 ⍴ ⍳9
0 1 2
3 4 5
6 7 8
,(comma)(Un)ravel (self-concat until the rank is reduced to 1):
    ,2 2 2 ⍴ ⍳8
0 1 2 3 4 5 6 7

Concatenate:

    a← 1 2 3 ⋄ b← 4 5 6
a,b

. (dot)N/AInner product f.g (where f and g are operators or functions):
    1 2 3 +.× 1 2 3
14
    1 2 3 +.= 1 2 4
2
Outer product ∘.g:
    0 1 2 ∘.+ 1 2 3
1 2 3
2 3 4
3 4 5
f⍨ switch (⍺ f⍨ ⍵ becomes ⍵ f ⍺; f⍨⍵ means ⍵ f ⍵):
    +⍨2
4
    1-⍨2
1
a⍨ constant:
    -1⍨⍳9
-1
N/A