|
|
@@ -1,252 +0,0 @@
|
|
|
-const char *VHELP =\
|
|
|
-": monadic const create a function that always yields x" "\n"\
|
|
|
-": dyadic bind bind y to symbol x" "\n"\
|
|
|
-":: monadic unbind unbind symbol x" "\n"\
|
|
|
-":: dyadic obverse insert inverse for x" "\n"\
|
|
|
-"+ monadic flip transpose matrix" "\n"\
|
|
|
-"+ dyadic plus add numbers" "\n"\
|
|
|
-"+. monadic fibonacci compute xth fibonacci number" "\n"\
|
|
|
-"+. dyadic gcd compute gcd(x, y)" "\n"\
|
|
|
-"+: monadic sin compute sin(x)" "\n"\
|
|
|
-"+: dyadic combine combine digits of x and y, same as 10_.(10_:),(10_:)" "\n"\
|
|
|
-"- monadic negate negate number" "\n"\
|
|
|
-"- dyadic minus subtract numbers" "\n"\
|
|
|
-"* monadic first yield first element of x" "\n"\
|
|
|
-"* dyadic times multiply numbers" "\n"\
|
|
|
-"*. monadic factorial x!" "\n"\
|
|
|
-"*. dyadic lcm compute lcm(x, y)" "\n"\
|
|
|
-"*: monadic double x * 2" "\n"\
|
|
|
-"*: dyadic replicate repeat y x times" "\n"\
|
|
|
-"% monadic reciprocal 1 / x" "\n"\
|
|
|
-"% dyadic divide divide numbers" "\n"\
|
|
|
-"%. monadic sqrt compute square root of x" "\n"\
|
|
|
-"%. dyadic root compute xth root of y" "\n"\
|
|
|
-"%: monadic halve x % 2" "\n"\
|
|
|
-"%: dyadic idivide same as % divide, but result is always integer" "\n"\
|
|
|
-"! monadic enum [0, x)" "\n"\
|
|
|
-"! dyadic mod modulo of numbers" "\n"\
|
|
|
-"!. monadic iota [1, x]" "\n"\
|
|
|
-"!. dyadic range [x, y] (also works for chars and even if x > y)" "\n"\
|
|
|
-"!: monadic odometer !:10 10 is 0 0,:0 1,: ... 1 0,:1 1,: ... 9 8,:9 9" "\n"\
|
|
|
-"!: dyadic chunks split y into x-sized chunks" "\n"\
|
|
|
-"^ monadic exp e^x" "\n"\
|
|
|
-"^ dyadic power raise number to a power" "\n"\
|
|
|
-"^. monadic nlog ln(x)" "\n"\
|
|
|
-"^. dyadic log log(y)/log(x)" "\n"\
|
|
|
-"= monadic permute generate permutations of x" "\n"\
|
|
|
-"= dyadic equals test whether x and y are equal" "\n"\
|
|
|
-"=. monadic occurences count occurences of elts, =.'Hello World!' is 0 0 0 1 0 0 0 1 0 2 0 0" "\n"\
|
|
|
-"=. dyadic mask mask one array in another, 'abxyzabayxxyabxyk'=.'xy' is 0 0 1 1 0 0 0 0 0 0 2 2 0 0 3 3 0" "\n"\
|
|
|
-"=: monadic classify assign unique index to each unique elt, =:'Hello World!' is 0 1 2 2 3 4 5 3 6 2 7 8" "\n"\
|
|
|
-"=: dyadic match same as = equals, but rank 0, so compares x and y as whole" "\n"\
|
|
|
-"~ monadic not logical not, nil udf () 0 4t.0 are not truthy, everything else is truthy" "\n"\
|
|
|
-"~ dyadic notequals test whether x and y are not equal" "\n"\
|
|
|
-"~. monadic sign sign of x, -1 for negative, 0 for 0, 1 for positive" "\n"\
|
|
|
-"~. dyadic insert insert x between elts of y, 0~.1 2 3 is 1 0 2 0 3" "\n"\
|
|
|
-"~: dyadic notmatch rank 0 version of ~ notequals" "\n"\
|
|
|
-"< monadic pred x - 1" "\n"\
|
|
|
-"< dyadic less test whether x is lesser than y" "\n"\
|
|
|
-"<. monadic floor round x down" "\n"\
|
|
|
-"<. dyadic lesseq test whether x is equal or lesser than y" "\n"\
|
|
|
-"<: monadic gradedown indices of array sorted descending" "\n"\
|
|
|
-"<: dyadic nudgeleft shift elts of y to the left filling gap with x" "\n"\
|
|
|
-"> monadic succ x + 1" "\n"\
|
|
|
-"> dyadic greater test whether x is greater than y" "\n"\
|
|
|
-">. monadic ceil round x up" "\n"\
|
|
|
-">. dyadic greatereq test whether x is equal or greater than y" "\n"\
|
|
|
-">: monadic gradeup indices of array sorted ascending" "\n"\
|
|
|
-">: dyadic nudgeright shift elts of y to the right filling gap with x" "\n"\
|
|
|
-", monadic enlist put x into 1-elt array" "\n"\
|
|
|
-", dyadic join concat x and y" "\n"\
|
|
|
-",. monadic enfile same as , enlist but with infinite rank, ,.1 2 3 is (,1),:(,2),:(,3)" "\n"\
|
|
|
-",. dyadic enpair put x and y into 2-elt array" "\n"\
|
|
|
-"# monadic count yield count of elts of x" "\n"\
|
|
|
-"# dyadic take take x first elts of y (or last if x < 0)" "\n"\
|
|
|
-"#. monadic where #.0 0 1 0 1 0 is 2 4" "\n"\
|
|
|
-"#. dyadic copy repeat each elt of x by corresponding number in y, 5 2 3 3#.0 2 2 1 is 2 2 3 3 3" "\n"\
|
|
|
-"#: monadic group #:'mississippi' is (,0),:1 4 7 10,:2 3 5 6,:8 9" "\n"\
|
|
|
-"#: dyadic buckets group elts of y into buckets according to x, e.g. 0 -1 -1 2 0#:a b c d e is (a,.e),:(),:(,d)" "\n"\
|
|
|
-"_ monadic nub mark all unique elts of x, e.g. _'abracadabra' yields 1 1 1 0 1 0 1 0 0 0 0" "\n"\
|
|
|
-"_ dyadic drop remove first x elts of y (or last if x < 0)" "\n"\
|
|
|
-"_. monadic unbits _.1 0 1 is 5" "\n"\
|
|
|
-"_. dyadic unbase 10_.4 5 6 is 456" "\n"\
|
|
|
-"_: monadic bits _:5 is 1 0 1" "\n"\
|
|
|
-"_: dyadic base 10_:4242 is 4 2 4 2" "\n"\
|
|
|
-"? monadic unique distinct elts of x, same as ]#._" "\n"\
|
|
|
-"? dyadic find find all indices of x in y" "\n"\
|
|
|
-"& monadic flatten flatten an array, same as ,//." "\n"\
|
|
|
-"& dyadic minand get min of two numbers (logical and for 0/1s)" "\n"\
|
|
|
-"| monadic reverse reverse an array" "\n"\
|
|
|
-"| dyadic maxor get max of two numbers (for 0/1s is same as logical or)" "\n"\
|
|
|
-"|. monadic round round x" "\n"\
|
|
|
-"|. dyadic rotate rotate array x times clockwise (-x for counterclockwise)" "\n"\
|
|
|
-"|: monadic depth find max depth of x, |:,,,y yields 3" "\n"\
|
|
|
-"|: dyadic windows yields all contiguous x-sized subarrays of y" "\n"\
|
|
|
-"@ monadic abs |x|" "\n"\
|
|
|
-"@ dyadic at pick elts from x by indices from y" "\n"\
|
|
|
-"@. monadic shuffle shuffle elts of x" "\n"\
|
|
|
-"@. dyadic member check whether x is in y" "\n"\
|
|
|
-"@: monadic infix shortcut for }{:" "\n"\
|
|
|
-"@: dyadic indexof yield index of x in y or #y if x not in y" "\n"\
|
|
|
-"{ monadic head first two elts of x, same as 2#" "\n"\
|
|
|
-"{ dyadic bin bin search, e.g. 1 3 5 7 9{8 9 0 yields 3 4 -1" "\n"\
|
|
|
-"{. monadic tail last elt of x" "\n"\
|
|
|
-"{. dyadic cut 1 3{.!.5 yields 2 3,:4 5" "\n"\
|
|
|
-"{: monadic prefixes prefixes of x, same as |}.\\." "\n"\
|
|
|
-"{: dyadic shl x << y" "\n"\
|
|
|
-"} monadic behead all elts of x except first, same as 1_" "\n"\
|
|
|
-"} dyadic xor x ^ y" "\n"\
|
|
|
-"}. monadic curtail all elts of x except last, same as -1_" "\n"\
|
|
|
-"}. dyadic band x & y" "\n"\
|
|
|
-"}: monadic suffixes suffixes of x, same as }.\\." "\n"\
|
|
|
-"}: dyadic shr x >> y" "\n"\
|
|
|
-"[ monadic factors compute prime factors of x" "\n"\
|
|
|
-"[ dyadic left yield x" "\n"\
|
|
|
-"[. monadic bnot ~x" "\n"\
|
|
|
-"[. dyadic bor x | y" "\n"\
|
|
|
-"[: monadic primes find primes in range [2, x]" "\n"\
|
|
|
-"[: dyadic parts split y into x parts" "\n"\
|
|
|
-"] monadic same yield x (i.e. identity)" "\n"\
|
|
|
-"] dyadic right yield y (i.e. right argument)" "\n"\
|
|
|
-"]. monadic sort sort x ascending, shortcut for ]@>:" "\n"\
|
|
|
-"]. dyadic outof the number of ways of picking x balls from a bag of y balls, e.g. 5].10 is 252" "\n"\
|
|
|
-"]: monadic unsort sort x descending, shortcut for ]@<:" "\n"\
|
|
|
-"]: dyadic explode split y by delim x" "\n"\
|
|
|
-"`. monadic symbol cast x to a symbol" "\n"\
|
|
|
-"`. dyadic apply1 apply x to y" "\n"\
|
|
|
-"`: monadic square x ^ 2" "\n"\
|
|
|
-"`: dyadic apply2 apply x to y (y is 2-elt array of args)" "\n"\
|
|
|
-"$ monadic shape yield shape of x" "\n"\
|
|
|
-"$ dyadic reshape reshape y to shape x" "\n"\
|
|
|
-"$. monadic repr yield string repr of x" "\n"\
|
|
|
-"$. dyadic format format y by template x, e.g. '{0}+{1}*{-1}+_'$.1 2 3 4 is 1+2*4+1" "\n"\
|
|
|
-"$: monadic eye identity matrix of size x" "\n"\
|
|
|
-"$: dyadic implode join y inserting x between" "\n"\
|
|
|
-"";
|
|
|
-
|
|
|
-const char *V2HELP =\
|
|
|
-"d. dyadic delete delete elt from y by index x" "\n"\
|
|
|
-"D. dyadic deleteInplace delete elt from y by index x (in-place)" "\n"\
|
|
|
-"p. monadic print print x" "\n"\
|
|
|
-"P. monadic println print x and a \\n" "\n"\
|
|
|
-"c. monadic putch print char x" "\n"\
|
|
|
-"s. monadic selfref1 monadic reference to current function or rhs of bind" "\n"\
|
|
|
-"s. dyadic selfref2 dyadic reference to current function or rhs of bind" "\n"\
|
|
|
-"F. monadic read read file (x=0 to read stdin)" "\n"\
|
|
|
-"F. dyadic write write file (y=0 to write to stderr)" "\n"\
|
|
|
-"t. dyadic cast cast y to type x" "\n"\
|
|
|
-"t. monadic type type of x, array=0, verb=1, symbol=2, number=3, char=4, nil=5, udf=6" "\n"\
|
|
|
-"r. monadic deal yield random elt of x" "\n"\
|
|
|
-"r. dyadic roll roll xdy (note: y is 0-based, so >xr.y for 1-based)" "\n"\
|
|
|
-"e. monadic eval eval expression, yields udf on parse error" "\n"\
|
|
|
-"i. monadic import load and eval source file" "\n"\
|
|
|
-"i. dyadic foreign call external function (lhs is array of arguments), e.g. .5i.'libm.so:dd:sin'" "\n"\
|
|
|
-"y. monadic system exec system command (yields output)" "\n"\
|
|
|
-"y. dyadic system2 exec system command with input" "\n"\
|
|
|
-"E. monadic exit exit with exit code" "\n"\
|
|
|
-"L. monadic lines shortcut for (4t.10)]:" "\n"\
|
|
|
-"L. dyadic tackleft prepend x to y" "\n"\
|
|
|
-"R. monadic setrecdepth set max recursion depth" "\n"\
|
|
|
-"R. dyadic tackright append x to y" "\n"\
|
|
|
-"v. monadic value get value of var x (udf if not defined)" "\n"\
|
|
|
-"h. monadic hex yield hexadecimal representation of num x"
|
|
|
-"x. monadic show identity for strings, same as $ repr for other" "\n"\
|
|
|
-"x. dyadic rematch match str y with regex (PCRE) x" "\n"\
|
|
|
-"X. dyadic extract extract all matches of regex x from y" "\n"\
|
|
|
-"";
|
|
|
-
|
|
|
-const char *AHELP =\
|
|
|
-"f\" each >\"1 2 3 yields 2 3 4" "\n"\
|
|
|
-"xf\" merge 1 2 3,\"a b c yields (1,.a),:(2,.b),:(3,.c)" "\n"\
|
|
|
-"f\". eachprior -\".1 2 2 3 5 6 yields 1 0 1 2 1" "\n"\
|
|
|
-"xf\". eachpriorwith 0-\".1 2 2 3 5 6 yields 1 1 0 1 2 1" "\n"\
|
|
|
-"f/ fold +/1 2 3 yields 6" "\n"\
|
|
|
-"xf/ foldwith 1+/1 2 3 yields 7" "\n"\
|
|
|
-"f\\ scan +\\1 2 3 yields 1 3 6" "\n"\
|
|
|
-"xf\\ scanwith 1+\\1 2 3 yields 1 2 4 7" "\n"\
|
|
|
-"f/. converge 1;_/.1 2 3 yields ()" "\n"\
|
|
|
-"f\\. converges 1;_\\.1 2 3 yields 1 2 3,:2 3,:(,3),:()" "\n"\
|
|
|
-"xf/. eachright 1-/.1 2 3 yields 0 1 2" "\n"\
|
|
|
-"xf\\. eachleft 1-\\.1 2 3 yields 0 -1 -2" "\n"\
|
|
|
-"f\": rank #\":1 2 3$1 yields 3 3, #\":inf 2 3$1 yields 1 1 1,:1 1 1" "\n"\
|
|
|
-"xf\": rank2 1 2 3 *:\":1 1 2 3 yields (,1),:2 2,:3 3 3" "\n"\
|
|
|
-"n` amend 'gw'0 3`'cross' yields 'grows', 1 0 -1(1+)`!.5 yields 2 3 3 4 6" "\n"\
|
|
|
-"f&. filter >;0&.-2!.2 yields 1 2, basically shortcut for ]#.f" "\n"\
|
|
|
-"f/: span =;' '/:'x y z' yields (,'x'),:(,'y'),:(,'z')" "\n"\
|
|
|
-"xf/: stencil 3+//:!10 yields 3 6 9 12 15 18 21 24, shortcut for f\"x|:" "\n"\
|
|
|
-"f;. reflex *;.5 yields 25, 5%;.2 yields 0.4" "\n"\
|
|
|
-"";
|
|
|
-const char *CHELP =\
|
|
|
-"f;g bond */;!.5 yields 120, +;1 5 yields 6, 5;- 1 yields 4" "\n"\
|
|
|
-"f?.x pick >;5?.((2*),:<)\"3 6 yields 6 5" "\n"\
|
|
|
-"f?:F while <;5?:>0 yields 5" "\n"\
|
|
|
-"n?:f repeat 5?:*;2 1 yields 32" "\n"\
|
|
|
-"a\\:f collect same as while/repeat, but yields array of intermediate iterations" "\n"\
|
|
|
-"f&:F if 1+&:+2 yields 2" "\n"\
|
|
|
-"f;:F monaddyad -;:+5 yields -5, 1-;:+5 yields 6" "\n"\
|
|
|
-"";
|
|
|
-
|
|
|
-const char *IHELP =\
|
|
|
-"inverse of a function f is a function ~f that undoes the effect of f" "\n"\
|
|
|
-"\n"\
|
|
|
-"f::~f obverse define inverse ~f for f" "\n"\
|
|
|
-"\n"\
|
|
|
-"f-:x inverse ~fx" "\n"\
|
|
|
-"xf-:y inverse2 (~fx)~f~fx" "\n"\
|
|
|
-"f^:Fx under ~FfFx" "\n"\
|
|
|
-"xf^:Fx under2 ~F(Fx)f(Fx)" "\n"\
|
|
|
-"";
|
|
|
-
|
|
|
-const char *SHELP =\
|
|
|
-"/ comment" "\n"\
|
|
|
-"5+5 / also comment" "\n"\
|
|
|
-"5+5/not comment (no whitespace before /)" "\n"\
|
|
|
-"abc foo bar f g x y z / symbols" "\n"\
|
|
|
-"nil udf / special, nil and undefined" "\n"\
|
|
|
-"'a'%2 / = nan, nan used to denote illegal numeric operation" "\n"\
|
|
|
-"+1 2 3 / = udf, attempt to transpose flat vector, udf/undefined used to denote illegal operation" "\n"\
|
|
|
-"5 5.5 -5 42 / number (double-precision floats)" "\n"\
|
|
|
-"1`000 1`000`000 /" "\n"\
|
|
|
-".5 .429 /" "\n"\
|
|
|
-"0xff 0o4 0b0101 /" "\n"\
|
|
|
-"nan inf /" "\n"\
|
|
|
-"'a' 'b' 'g' / chars (bytes)" "\n"\
|
|
|
-"4t.0 / 0 NUL byte" "\n"\
|
|
|
-"(4t.0),:(4t.16),:(4t.22) /" "\n"\
|
|
|
-"1 2 3 / numbers array" "\n"\
|
|
|
-"'hello world!' 'bla''bla' / quote, array of chars" "\n"\
|
|
|
-",'a' / 1-char string" "\n"\
|
|
|
-",1 / 1-elt array" "\n"\
|
|
|
-"() / unit, empty array" "\n"\
|
|
|
-"1,:(5+5),:1 2 3 / strand, mixed array literal" "\n"\
|
|
|
-"-1 / negative num literal" "\n"\
|
|
|
-"- 1 / application of - negate to 1" "\n"\
|
|
|
-"-1 -2 -3 / array of negative nums" "\n"\
|
|
|
-"- 1 2 3 / application of - negate to an array of nums" "\n"\
|
|
|
-"5-5 / array of numbers 5 and -5" "\n"\
|
|
|
-"5- 5 / 5 minus 5" "\n"\
|
|
|
-"+ / verb" "\n"\
|
|
|
-"5+5 / dyadic expr" "\n"\
|
|
|
-"#1 2 3 / monadic expr (no left side)" "\n"\
|
|
|
-"+/ *;. / adverb" "\n"\
|
|
|
-"+;1 -;* +^:^. / conjunction" "\n"\
|
|
|
-":x+y / function literal" "\n"\
|
|
|
-":1 / function that always yields 1" "\n"\
|
|
|
-"x:123 / bind name (symbol)" "\n"\
|
|
|
-"sq:*;. /" "\n"\
|
|
|
-"fac:*/1+! / bind function" "\n"\
|
|
|
-"f:x+y /" "\n"\
|
|
|
-"f:-x / overload function by arity" "\n"\
|
|
|
-"f 5 / = -5" "\n"\
|
|
|
-"5 f 5 / = 10" "\n"\
|
|
|
-"*/!. / hook, fgx -> f(g(x)), xfgy -> f(g(x, y))" "\n"\
|
|
|
-"+/%# / fork, fghx -> g(f(x), h(x)), xfghy -> g(f(x), h(y))" "\n"\
|
|
|
-"1+! / over, nfgx -> f(n, g(x)), xnfgy -> f(n, g(x, y))" "\n"\
|
|
|
-"1+ / bond, nfx -> f(n, x), xnfy -> f(n, f(x, y))" "\n";
|
|
|
-
|
|
|
-const char *HELP = "\\0\thelp on syntax\n"\
|
|
|
-"\\+\thelp on verbs\n"\
|
|
|
-"\\a\thelp on additional verbs\n"\
|
|
|
-"\\\"\thelp on adverbs\n"\
|
|
|
-"\\;\thelp on conjunctions\n"\
|
|
|
-"\\-:\thelp on inverses\n";
|