J言語チートシート
代入操作
code:assign.ijs
x=: y NB. global assign value of y to x
x=. y NB. local assign value of y to x
('a';'b';'c')=: n m w NB. "
'a b c'=: n;m;w NB. "
('a';'b';'c')=: n;m;w NB. "
論理演算
code:logic.ijs
x *. y NB. x and y
x +. y NB. x or y
-. y NB. not y
x *: y NB. not (x and y)
x +: y NB. not (x or y)
x -: y NB. x matches y (same shape and values: identical, atomic result)
x = y NB. x equals y (same shape collection of item comparisons)
x >: y NB. x >= y
x <: y NB. x <= y
数値表現
code:numerical-representation.ijs
Yx NB. Y number, literal x: extended integer (bigint)
XeY NB. X number, literal e, Y pos/neg integer: scientific notation X*10^Y XpY NB. X * pi^Y
XxY NB. X * e^Y
数値演算
code:numerical-math.ijs
__ NB. negative infinity float x | y NB. y modulo x
Xx % Yx = XrY NB. literal x and r
x: y NB. rational number from float y
x:^:_1 y NB. float from rational number
(2 x: XrY) = X Y
+. XjY = x y
*. XjY = (| x) 'ANGLE-RAD'
(128 !: 5) y NB. is y _. (NaN)
x + y NB. add
+ XjY = Xj_Y NB. conjugate
x - y NB. subtract
- y NB. negate
x * y NB. multiply
*: y = y * y
% y = 1 % y
+: y = y * 2
-: y = y % 2
x ^ y NB. pow(x, y)
^y NB. e^y
x %: y = y ^ % x
%: y NB. sqrt(y)
x ^. y NB. log(y, base=x)
^. y NB. log(y, base=e)
x +. y NB. GCD
x *. y NB. LCM
#. y NB. y binary list as number #: y NB. y number as a binary list x #. y NB. y base list as specified by spec x as a number x #: y NB. y number to base list as specified by spec x . y NB. round up
<. y NB. round down
x >. y NB. max(x, y)
x <. y NB. min(x, y)
: y = y + 1
<: y = y - 1
! y NB. factorial(y)
x ! y NB. # of combinations of x selected from y (n k)
? y NB. random integer in range 0, y-1 ? 0 NB. random float in range [0, 1)
x ? y NB. randomly select x integers in range 0, y-1 o. y NB. y * pi
n o. y NB. trigonometric and other functions determined by n applied on y
q: y NB. prime factors of y
x q: y NB. list of x first exponents of y prime factors for full list
p: y NB. get (y-1)'th prime
y p. x = +/ y * x ^ i. # y NB. calculate polynomial specified by coefficients y on x
(m, roots) p. x = m * */(x - roots) NB. calculate coefficients
(< C ,. E) p. x NB. C,E pairs of a coefficient and exponent to get polynomial
NB. a polynomial function can be obtained with y&p.
p. y NB. 1. roots of polynomial specified by coefficients y m; roots NB. 2. coefficients of polynomial specified by roots y m; roots NB. m such that: p(x) = m*(x-r1)*(x-r2)*...*(x-rn)
x d. n NB. n'th derivative of x analytic x D. n NB. n'th derivative of x numeric sergeyqz/jcheatsheet
引用元