Skip to content

Instantly share code, notes, and snippets.

@suhr
Last active January 17, 2023 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suhr/05ec5e2adf4385fef579ce352f258251 to your computer and use it in GitHub Desktop.
Save suhr/05ec5e2adf4385fef579ce352f258251 to your computer and use it in GitHub Desktop.
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 6.
SYNTAX NAME DESCRIPTION EXAMPLE
+/x Sum Sum all value in x +/1 2 3 4 5 → 15
-':x Deltas Pairwise differences in x -':1 2 3 4 → 1 1 1 1
|+x Rotate matrix Rotate x counterclockwise |+3 3#!9 → (2 5 8; 1 4 7;0 3 6)
x@<x Sort Sort x {x@<x}@8 3 7 1 → 1 3 7 8
?x,y Set Union Unique elements from x and y ?"abac","adob" → "abcdo"
x^x^y Intersection Common elements from x and y {?x^x^y}["abac";"adob"] → "aba"
x|-x Absolute value Absolute value of x {x|-x}@-1 → 1
*/y#x Power x in power of y (y>0) {*/y#x}[2;5] → 32
y@(#y)!x+!#y Rotate left Rotate y by x elements to the left {y@(#y)!x+!#y}[3;"abcde"] → "deabc"
`c$x-(32*&97 26)x Uppercase Upper case of all alphabetic chars {`c$x-(32*&97 26)x}@"happy" → "HAPPY"
@[x;i;:;v] Update Update value at x[i] with v a:+`a`b!(0 1 ; 2 3);@[a;0;:;(3,4)] → +`a`b!(3 1;4 3)
|/x Max, Any Largest element in x |/3 5 2 → 5 |/1 0 1 → 1
&/x Min, All Smallest element in x &/3 5 2 → 2 &/1 1 1 → 1
(+/x)%#x Avg Arithmetic mean {(+/x)%#x}@1 2 3 4 5 → 3.0
z@y/(!y@<x)x Dyadic transpose x⍉y⍴z {z@y/(!y@<x)x}[2 0 1; 2 3 4; `c$"A"+!24] → "AMBNCODPEQFRGSHTIUJVKWLX"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment