-
Notifications
You must be signed in to change notification settings - Fork 1
Commands
(
)
()
)+
()+
)++
()++
)~
()~
)!
()!
)#
)##
)=
[
]
[]
]S
[]S
]:
[]:
];
/]
/]=
/]%
]*
]=
]%
.
type
form
tform
>Q
>A
>M
S
>S
>N
N
D
>D
>F
>E
>~
~>
>~`
>!?
>!+
>!-
>?
~>?
N>d
>TT
>>M
,>M
js>
>js
UN
$T
$F
$PI
$E
$PHI
$rng
$LINE
$FILE
$PWD/
$CWD/
$~/
$W
$N
$P
$L*
$ABC
$abc
g@
g;
g;;
n\
$NOW
$THREAD
$ENV
$
@>
@$
@$$
@:
@::
@;
@;;
@#
@##
->
_$
+$
>$
i>
>o
n>o
f>o
tf>o
dup
dups
dupd
over
ddup
edup
pick
pop
clr
nip
ppop
qpop
nix
swap
rev
swapd
tuck
trade
rot
rot_
roll
roll_
dip
\
#
Q
@@
@~
@
;
;;
;>
;;>
g@@
g@~
&#
&&#
|#
||#
?#
??#
*#
!#
!Q
~Q
>!
'
'_
end
_#
E
I
I?
|_
|~
|^
X>b
b>X
>n/d
prec?
_
__
_`
+
++
+`
<+
+>
+<
>+
,+
,+`
-
--
-`
*
**
*`
/
/~
//
/`
%
/%
%%
%`
%`~
^
^~
^^
^`
e^
abs
sin
cos
tan
sin_
cos_
tan_
tan_II
sinh
cosh
tanh
sinh_
cosh_
tanh_
log
ln
logX
P?
P/
!
!`
&
&&
&`
&&`
|
||
|`
||`
<=>
<=>`
=
=`
==
==`
!=
!=`
!==
!==`
<
<`
>
>`
<=
<=`
>=
>=`
b~
b&
b|
b^
b<<
b>>
b>>>
:
:r
:`
:*
:/
:=
:*=
:/=
:%
:*%
:/%
:-
:?
:?`
len
~len
shape
shape^
rank
rank^
,
,,
,'
,,'
,`
,_
,,_
tk
~tk
~tk`
dp
~dp
~dp`
flat
~flat
rflat
rep
~rep
cyc
~cyc
I*
I^
mold
itr
~itr
fold_
~fold_
>kv
=>kv
>k
>v
a>b
a-b
O>a
O-a
a>O
a-O
I>a
I-a
a>I
a-I
shuf
perm
comb
^set
Q*
tpose
raxes
paxes
pad
padl
padc
pad`
padl`
padc`
S>c
c>S
<>
<>:
c<>
w<>
n<>
s<>
><
c><
w><
n><
A>a
a>A
>Aa
/?
/?&
/?`
/?'
/?*
/?^
/?$
/#
/#^
map
~map
~map||
~map||>
tap
each
mapf
~mapf
~mapf~
%map
zip
zip~
tbl
tblf
rmap
dmap
fold
~fold
foldr
rfold
rfoldr
fold~
foldr~
scan
~scan
scanr
+/
*/
&/
|/
walk
fltr
~fltr
any
~any
all
~all
tk*
dp*
find
~find
find:
del
uniq
uniq~
sort
sort~
part
group
~group
span
pack
union
intxn
diff
~_
~$
~^
~^`
~|>
~||
~||>
~//
~>>
~<
~io
~memo
~memo&
~memo`
~$_
~%
~%Q
~?
~@
~%@
~+%@
~!?
~!?_
~?[]
~?!>
~sleep
~delay
~delay`
~/n
~/%
~/%n
~/%<
~/n`
~>-<
~>-^
~>-$
~>~-
~^UN
~^ERR
~^BAK
~^NEW
~^OLD
~^CLR
_/<>
_/><
_/x
_/x_
_/_x
S>b
b>S
~S>b
~b>S
fs>
fs>b
fs>n
>fs
b>fs
^>fs
b^>fs
fs@
fs:
fs::
fs*
fs*?
tcp>
tcp>b
>tcp
b>tcp
CMD: (
Stack:
->
Start FN.
CMD: )
Stack:
-> FN
End FN.
CMD: ()
Stack:
-> FN
Empty FN.
CMD: )+
Stack:
-> FN
CMD: ()+
Stack:
a -> FN
CMD: )++
Stack:
-> FN
CMD: ()++
Stack:
a -> FN
CMD: )~
Stack:
-> TASK
CMD: ()~
Stack:
-> TASK
Empty TASK.
CMD: )!
Stack:
->
CMD: ()!
Stack:
-> TRY
Empty TRY.
CMD: )#
Stack:
->
CMD: )##
Stack:
->
CMD: )=
Stack:
->
CMD: [
Stack:
->
Start ARR/MAP.
CMD: ]
Stack:
-> ARR
End ARR.
CMD: []
Stack:
-> ARR
Empty ARR.
CMD: ]S
Stack:
-> STR
CMD: []S
Stack:
-> STR
Empty STR.
CMD: ]:
Stack:
-> MAP
End MAP.
CMD: []:
Stack:
-> MAP
Empty MAP.
CMD: ];
Stack:
-> MAP
CMD: /]
Stack:
-> _
CMD: /]=
Stack:
-> _
CMD: /]%
Stack:
-> _
CMD: ]*
Stack:
-> _
CMD: ]=
Stack:
-> _
CMD: ]%
Stack:
-> _
CMD: .
Stack:
->
Magic dot.
CMD: type
Stack:
a -> STR
Type of a.
CMD: form
Stack:
a -> STR
a as formatted string.
CMD: tform
Stack:
a -> STR
form with nested indentation.
CMD: >Q
Stack:
a -> STR
Converts a to SEQ.
CMD: >A
Stack:
a -> ARR
Converts a to ARR.
CMD: >M
Stack:
a -> ARR
Converts a to MAP.
CMD: S
Stack:
a' -> STR'
Atomic >S.
CMD: >S
Stack:
a -> STR
Converts a to STR.
CMD: >N
Stack:
a -> NUM
Converts a to NUM.
CMD: N
Stack:
a' -> NUM'
Atomic >N.
CMD: D
Stack:
a' -> DBL'
Atomic >D.
CMD: >D
Stack:
a -> DBL
Converts a to DBL.
CMD: >F
Stack:
a -> FN
Converts a to FN.
CMD: >E
Stack:
(a >STR) (b >STR) -> ERR
Converts a to ERR with message b.
CMD: >~
Stack:
a -> TASK
Converts a to TASK.
CMD: ~>
Stack:
a -> FUT
Converts a to FUT.
CMD: >~`
Stack:
a -> OBS
Converts a to OBS.
CMD: >!?
Stack:
a -> TRY
Converts a to TRY.
CMD: >!+
Stack:
a -> TRY
Converts a to a TRY that succeeds.
CMD: >!-
Stack:
a -> TRY
Converts a to a TRY that fails.
CMD: >?
Stack:
a -> TF
Converts a to TF.
CMD: ~>?
Stack:
(a >OBS) -> TASK[TF]
OBS-specific >?.
CMD: N>d
Stack:
(a >NUM) (b >NUM)' -> STR
Converts a to an STR formatted to b's specifications.
CMD: >TT
Stack:
a b -> _
Converts a to type of b.
CMD: >>M
Stack:
(a >STR)' -> MAP'
>M using a multiline string.
Each line of a is #ed, and the resulting top 2 stack items form each
key-value pair.
`` >>M
"a" 1
"b" 2
"c" 3
`
-> ["a"=>1 "b"=>2 "c"=>3]:
CMD: ,>M
Stack:
a -> MAP
>M that first pairs elements of a.
CMD: js>
Stack:
(a >STR)' -> _'
Converts a from JSON to ANY.
g; js>
{"a": 1, "b": 2, "c": [3, 4]}
-> ["b"=>2 "c"=>[3 4] "a"=>1]:
CMD: >js
Stack:
a -> STR
Converts a from ANY to JSON.
["a" 1, "b" 2, "c" [3 4] , ]: >js
-> "{\"a\":1,\"b\":2,\"c\":[3,4]}"
CMD: UN
Stack:
-> UN
UN
CMD: $T
Stack:
-> TF
True.
CMD: $F
Stack:
-> TF
False.
CMD: $PI
Stack:
-> NUM
π (Pi).
CMD: $E
Stack:
-> NUM
e (Euler's number).
CMD: $PHI
Stack:
-> NUM
Φ (Golden Ratio).
CMD: $rng
Stack:
-> NUM
Uniformly random number.
CMD: $LINE
Stack:
-> NUM
Current line number of program execution.
CMD: $FILE
Stack:
-> STR
Current file of program execution.
CMD: $PWD/
Stack:
-> STR
Current working directory at start of program execution.
CMD: $CWD/
Stack:
-> STR
Current working directory at current state in program execution.
CMD: $~/
Stack:
-> STR
Home directory.
CMD: $W
Stack:
-> SEQ[NUM*]
Infinite SEQ of 0 to ∞.
CMD: $N
Stack:
-> SEQ[NUM*]
Infinite SEQ of 1 to ∞.
CMD: $P
Stack:
-> SEQ[NUM*]
Infinite SEQ of primes.
CMD: $L*
Stack:
-> ARR[STR*]
ARR of lines of currently-executing file.
CMD: $ABC
Stack:
-> STR
UPPERCASE alphabet.
CMD: $abc
Stack:
-> STR
lowercase alphabet.
CMD: g@
Stack:
-> STR | UN
Current line.
CMD: g;
Stack:
-> STR | UN
Next line.
CMD: g;;
Stack:
-> STR | UN
Previous line.
CMD: n\
Stack:
-> STR
Newline character.
CMD: $NOW
Stack:
-> NUM
Number of milliseconds since UNIX epoch (January 1, 1970 00:00:00 UTC).
CMD: $THREAD
Stack:
-> STR
Name of current thread.
CMD: $ENV
Stack:
-> MAP[(STR => STR)*]
Environment variables.
CMD: $
Stack:
-> MAP[(STR => _)*]
Current scope.
CMD: @>
Stack:
a -> _
Imports top of the stack from another sclin file.
CMD: @$
Stack:
(a >FN)' ->
Loads ID a into local scope.
"outer"=$a ( \a @$ a ) # $a
#a "inner"
-> "inner" "outer"
CMD: @$$
Stack:
(a >FN) ->
Loads ID a into global scope.
\a @$$ ( "inner" =$a $a ) # a
#a "outer"
-> "inner" "outer"
CMD: @:
Stack:
(a >FN) -> STR | UN
@$ and get as STR.
CMD: @::
Stack:
(a >FN) -> STR | UN
@$$ and get as STR.
CMD: @;
Stack:
(a >FN) -> FN | UN
@$ and get as FN.
CMD: @;;
Stack:
(a >FN) -> FN | UN
@$$ and get as FN.
CMD: @#
Stack:
x* (a >FN) -> _*
CMD: @##
Stack:
x* (a >FN) -> _*
CMD: ->
Stack:
_* (a >FN) -> _*
Stores stack items into local variables defined by a.
Somewhat analogous to function arguments in other languages.
1 2 3 ;
( a b c ) -> $c $b $a
-> 3 2 1
CMD: _$
Stack:
->
Clears local scope.
CMD: +$
Stack:
(a >MAP[(STR => _)*]) ->
Appends a to the local scope.
CMD: >$
Stack:
(a >MAP[(STR => _)*]) ->
CMD: i>
Stack:
-> STR
Line from STDIN.
CMD: >o
Stack:
(a >STR) ->
Sends a to STDOUT.
CMD: n>o
Stack:
(a >STR) ->
>os a with trailing newline.
CMD: f>o
Stack:
a ->
CMD: tf>o
Stack:
a ->
CMD: dup
Stack:
a -> a a
CMD: dups
Stack:
a* -> a* ARR[a*]
CMD: dupd
Stack:
a b -> a a b
CMD: over
Stack:
a b -> a b a
CMD: ddup
Stack:
a b -> a b a b
CMD: edup
Stack:
a b c -> a b c a b c
CMD: pick
Stack:
(a @ n) b* (n >NUM) -> a b* a
dups nth item from top of stack.
4 3 2 1 0 3pick
-> 4 3 2 1 0 3
4 3 2 1 0 1_ pick
-> 4 3 2 1 0 4
CMD: pop
Stack:
_ ->
CMD: clr
Stack:
_* ->
CMD: nip
Stack:
_ b -> b
CMD: ppop
Stack:
_ _ ->
CMD: qpop
Stack:
_ _ _ ->
CMD: nix
Stack:
(a @ n) b* (n >NUM) -> _*
pops nth item from top of stack.
CMD: swap
Stack:
a b -> b a
CMD: rev
Stack:
a* -> _*
Reverses stack.
CMD: swapd
Stack:
a b c -> b a c
CMD: tuck
Stack:
a b -> b a b
CMD: trade
Stack:
(a @ n) b* c (n >NUM) -> c b* a
swaps c with nth item from top of stack.
4 3 2 1 0 3trade
-> 4 0 2 1 3
4 3 2 1 0 1_ trade
-> 0 3 2 1 4
CMD: rot
Stack:
a b c -> b c a
CMD: rot_
Stack:
a b c -> c a b
CMD: roll
Stack:
(a @ n) b* (n >NUM) -> b* a
rots to top nth item from top of stack.
4 3 2 1 0 3roll
-> 4 2 1 0 3
4 3 2 1 0 1_ roll
-> 3 2 1 0 4
CMD: roll_
Stack:
b* c (n >NUM) -> (c @ n) b*
rot_s c to nth from top of stack.
4 3 2 1 0 3roll_
-> 4 0 3 2 1
4 3 2 1 0 1_ roll_
-> 0 4 3 2 1
CMD: dip
Stack:
a* b (f >FN) -> _* b
CMD: \
Stack:
a -> FN[a]
Wraps a in FN.
CMD: #
Stack:
a* f -> _*
Executes f.
1 2 ( 3 + 4 ) #
-> 1 5 4
CMD: Q
Stack:
f' -> _'
Evaluates f (# but only preserves resulting top of stack).
1 2 ( dups 3+` ) Q
-> 1 2 [1 2 3]
CMD: @@
Stack:
a* (n >NUM) -> _*
#s nth line.
CMD: @~
Stack:
a* (n >NUM) -> _*
#s nth line relative to current line.
CMD: @
Stack:
a* -> _*
#s current line.
CMD: ;
Stack:
a* -> _*
#s next line.
CMD: ;;
Stack:
a* -> _*
#s previous line.
CMD: ;>
Stack:
a* -> _*
#s first subsequent line whose leading whitespace count <= current line's leading whitespace count.
CMD: ;;>
Stack:
a* -> _*
#s first preceding line whose leading whitespace count <= current line's leading whitespace count.
CMD: g@@
Stack:
(n >NUM) -> STR | UN
nth line.
CMD: g@~
Stack:
(n >NUM) -> STR | UN
nth line relative to current line.
CMD: &#
Stack:
a* (b >TF) f -> _*
#s f if b is truthy.
CMD: &&#
Stack:
a* (b >TF) f -> _*
Non-destructive &#;
executes f on b if b is truthy,
otherwise keeps b on stack.
CMD: |#
Stack:
a* (b >TF) f -> _*
#s f if b is falsy.
CMD: ||#
Stack:
a* (b >TF) f -> _*
Non-destructive |#;
executes f on b if b is falsy,
otherwise keeps b on stack.
CMD: ?#
Stack:
a* (b >TF) f g -> _*
#s f if b is truthy; else #s g.
CMD: ??#
Stack:
a* (b >MAP) -> _*
Iterates through each key-value pair of b.
For each pair: if the Q of the key is truthy, then #s the value and
short-circuits.
CMD: *#
Stack:
a* f (n >NUM) -> _*
#s f n times.
CMD: !#
Stack:
a* f g -> _*
Tries to # f; on error, pushes caught ERR and #s g.
CMD: !Q
Stack:
f' -> TRY'
Qs f and wraps the result in a TRY.
CMD: ~Q
Stack:
f' -> TASK'
Wraps f in a delayed, potentially asynchronous computation.
CMD: >!
Stack:
(e ERR) ->
Throws e.
CMD: '
Stack:
(a >ARR) f -> ARR
#s f on a as if it were a stack.
[1 2 3 4] ( 5 swap ) '
-> [1 2 3 5 4]
CMD: '_
Stack:
(a* >ARR) f -> _*
#s f on the stack as if it were an ARR.
1 2 3 4 1.+.map '_
-> 2 3 4 5
CMD: end
Stack:
->
Clears code queue, similar to the "break" keyword in other languages.
CMD: _#
Stack:
a ->
Clears code queue and #s top of stack.
CMD: E
Stack:
(a >NUM)' (b >NUM)' -> NUM'
a * 10 ^ b
CMD: I
Stack:
(a >NUM)' -> NUM'
Rounds a towards 0.
CMD: I?
Stack:
(a >NUM)' -> TF'
Whether a is an integer.
CMD: |_
Stack:
(a >NUM)' -> NUM'
Rounds a towards -∞.
CMD: |~
Stack:
(a >NUM)' -> NUM'
Rounds a to nearest integer.
CMD: |^
Stack:
(a >NUM)' -> NUM'
Rounds a towards ∞.
CMD: X>b
Stack:
(a >NUM)' (b >NUM)' -> ARR[NUM*]'
Converts a from decimal to ARR of base-b digits.
153 2X>b
-> [1 0 0 1 1 0 0 1]
153 16X>b
-> [9 9]
CMD: b>X
Stack:
(a >ARR[>NUM*]) (b >NUM)' -> NUM'
Converts base-b digits to decimal.
[1 0 0 1 1 0 0 1] 2b>X
-> 153
[9 9] 16b>X
-> 153
CMD: >n/d
Stack:
(a >NUM)' -> ARR[NUM NUM]'
Converts a to a numerator-denominator pair.
4 6/ >n/d
-> [2 3]
$PI >n/d
-> [68417829380157871863019543882359730131241 21778071482940061661655974875633165533184]
CMD: prec?
Stack:
(a >NUM)' -> TF'
Whether a is an exact value (i.e. represented in full precision).
2 3/ prec?
-> $T
$PI prec?
-> $F
CMD: _
Stack:
(a >NUM)' -> NUM'
-a
CMD: __
Stack:
(a >STR)' -> STR'
Atomic _`.
CMD: _`
Stack:
a -> _
Reverses a.
CMD: +
Stack:
(a >NUM)' (b >NUM)' -> NUM'
a + b
CMD: ++
Stack:
(a >STR)' (b >STR)' -> STR'
Atomic +`.
CMD: +`
Stack:
a b -> _
Concatenates a and b.
CMD: <+
Stack:
a b[_*] -> [a b*]
Prepends a to b.
CMD: +>
Stack:
a[_*] b -> [a* b]
Appends b to a.
CMD: +<
Stack:
[a, b*] -> a [b*]
Uncons; push first item and rest of a.
CMD: >+
Stack:
a -> [_*] _
Unsnoc; push last item and rest of a.
CMD: ,+
Stack:
a (b >FN) -> FN
FN-specific <+.
Wraps a in ARR and uses ,_ to preserve a's value.'
CMD: ,+`
Stack:
a (b >FN) -> FN
FN-specific +`.
Uses ,_ to preserve the values of a's elements.'
CMD: -
Stack:
(a >NUM)' (b >NUM)' -> NUM'
a - b
CMD: --
Stack:
(a >STR)' (b >STR)' -> STR'
Atomic -`.
CMD: -`
Stack:
a b -> _
Remove occurrences of b from a.
If a is MAP, then removal is performed on keys instead of values.
[1 2 3 4] 2-`
-> [1 3 4]
[0 1, 2 3, ]: 2-`
-> [0=>1]:
CMD: *
Stack:
(a >NUM)' (b >NUM)' -> NUM'
a * b
CMD: **
Stack:
(a >STR)' (b >NUM)' -> STR'
Atomic *`.
CMD: *`
Stack:
a b -> _
a replicated according to b.
If b is iterable, then a and b are recursively zipped together and
replicated.
[1 2 3 4] [0 2 0 3] *` >A
-> [2 2 4 4 4]
[1 2 3 4] 3*` >A
-> [1 2 3 4 1 2 3 4 1 2 3 4]
CMD: /
Stack:
(a >NUM)' (b >NUM)' -> NUM'
a / b. Throws error if b is 0.
CMD: /~
Stack:
(a >NUM)' (b >NUM)' -> NUM'
Integer /.
CMD: //
Stack:
(a >STR)' (b >NUM)' -> SEQ[STR*]'
Atomic /`.
CMD: /`
Stack:
a (b >NUM)' -> SEQ
a chunked to size b.
[1 2 3 4 5] 2/` >A
-> [[1 2] [3 4] [5]]
CMD: %
Stack:
(a >NUM)' (b >NUM)' -> NUM'
a (mod b)
CMD: /%
Stack:
(a >NUM)' (b >NUM)' -> NUM' NUM'
Results of /~ and % on a and b.
CMD: %%
Stack:
(a >STR)' (b >NUM)' -> SEQ[STR*]'
Atomic %`.
CMD: %`
Stack:
a (b >NUM)' -> SEQ
a windowed to size b.
[1 2 3 4 5] 3%` >A
-> [[1 2 3] [2 3 4] [3 4 5]]
CMD: %`~
Stack:
a (b >NUM)' (c >NUM)' -> SEQ
%` with extra skip parameter c.
[1 2 3 4 5] 3 2%` >A
-> [1 2 3 4 5] [[3]]
CMD: ^
Stack:
(a >NUM)' (b >NUM)' -> NUM'
a ^ b. Throws error if result would be a complex number.
CMD: ^~
Stack:
(a >NUM)' (b >NUM)' -> NUM'
^ but b is coerced to int.
CMD: ^^
Stack:
(a >STR)' (b >NUM)' -> SEQ[STR*]'
Atomic ^`.
CMD: ^`
Stack:
a (n >NUM)' -> SEQ'
Cartesian power of seed a to n.
"abc" 3^` >A
-> ["aaa" "aab" "aac" "aba" "abb" "abc" "aca" "acb" "acc" "baa" "bab" "bac" "bba" "bbb" "bbc" "bca" "bcb" "bcc" "caa" "cab" "cac" "cba" "cbb" "cbc" "cca" "ccb" "ccc"]
CMD: e^
Stack:
(a >NUM)' -> NUM'
e ^ a
CMD: abs
Stack:
(a >NUM)' -> NUM'
Absolute value of a.
CMD: sin
Stack:
(a >NUM)' -> NUM'
Sine of a.
CMD: cos
Stack:
(a >NUM)' -> NUM'
Cosine of a.
CMD: tan
Stack:
(a >NUM)' -> NUM'
Tangent of a.
CMD: sin_
Stack:
(a >NUM)' -> NUM'
Arcsine of a.
CMD: cos_
Stack:
(a >NUM)' -> NUM'
Arccosine of a.
CMD: tan_
Stack:
(a >NUM)' -> NUM'
Arctangent of a.
CMD: tan_II
Stack:
(a >NUM)' (b >NUM)' -> NUM'
Arctangent of a with b as quadrant.
CMD: sinh
Stack:
(a >NUM)' -> NUM'
Hyperbolic sine of a.
CMD: cosh
Stack:
(a >NUM)' -> NUM'
Hyperbolic cosine of a.
CMD: tanh
Stack:
(a >NUM)' -> NUM'
Hyperbolic tangent of a.
CMD: sinh_
Stack:
(a >NUM)' -> NUM'
Hyperbolic arcsine of a.
CMD: cosh_
Stack:
(a >NUM)' -> NUM'
Hyperbolic arccosine of a.
CMD: tanh_
Stack:
(a >NUM)' -> NUM'
Hyperbolic arctangent of a.
CMD: log
Stack:
(a >NUM)' (b >NUM)' -> NUM'
Base b logarithm of a.
CMD: ln
Stack:
(a >NUM)' -> NUM'
Natural logarithm of a.
CMD: logX
Stack:
(a >NUM)' -> NUM'
Base-10 logarithm of a.
CMD: P?
Stack:
(a >NUM)' -> NUM'
Whether a is prime. Uses a strong pseudo-primality test with a 1/1e12
chance of being wrong.
CMD: P/
Stack:
(a >NUM)' -> MAP[(NUM => NUM)*]
Prime-factorizes a into pairs of prime y and frequency z.
340P/
-> [2=>2 5=>1 17=>1]:
CMD: !
Stack:
(a >TF)' -> TF'
Atomic !`.
CMD: !`
Stack:
(a >TF) -> TF
Logical NOT.
CMD: &
Stack:
a' b' -> (a | b)'
Atomic &`.
CMD: &&
Stack:
(a >TF)' (b >TF)' -> TF'
Atomic &&`.
CMD: &`
Stack:
a b -> a | b
Minimum of a and b.
CMD: &&`
Stack:
(a >TF) (b >TF) -> TF
Logical AND of a and b.
CMD: |
Stack:
a' b' -> (a | b)'
Atomic |`.
CMD: ||
Stack:
(a >TF)' (b >TF)' -> TF'
Atomic ||`.
CMD: |`
Stack:
a b -> a | b
Maximum of a and b.
CMD: ||`
Stack:
(a >TF) (b >TF) -> TF
Logical OR of a and b.
CMD: <=>
Stack:
a' b' -> (-1 | 0 | 1)'
Atomic <=>`.
CMD: <=>`
Stack:
a b -> -1 | 0 | 1
Comparison (-1, 0, or 1 depending on whether a is less than, equal to, or
greater than b).
CMD: =
Stack:
a' b' -> TF'
Atomic =`.
CMD: =`
Stack:
a b -> TF
Whether a loosely equals b.
CMD: ==
Stack:
a' b' -> TF'
Atomic ==`.
CMD: ==`
Stack:
a b -> TF
Whether a strictly equals b.
CMD: !=
Stack:
a' b' -> TF'
Atomic !=`.
CMD: !=`
Stack:
a b -> TF
Whether a does not loosely equal b.
CMD: !==
Stack:
a' b' -> TF'
Atomic !=`.
CMD: !==`
Stack:
a b -> TF
Whether a does not loosely equal b.
CMD: <
Stack:
a' b' -> TF'
Atomic <`.
CMD: <`
Stack:
a b -> TF
Whether a is less than b.
CMD: >
Stack:
a' b' -> TF'
Atomic >`.
CMD: >`
Stack:
a b -> TF
Whether a is greater than b.
CMD: <=
Stack:
a' b' -> TF'
Atomic <=`.
CMD: <=`
Stack:
a b -> TF
Whether a is less than or equal to b.
CMD: >=
Stack:
a' b' -> TF'
Atomic >=`.
CMD: >=`
Stack:
a b -> TF
Whether a is greater than or equal to b.
CMD: b~
Stack:
(a >NUM)' -> NUM'
Bitwise NOT.
CMD: b&
Stack:
(a >NUM)' (b >NUM)' -> NUM'
Bitwise AND.
CMD: b|
Stack:
(a >NUM)' (b >NUM)' -> NUM'
Bitwise OR.
CMD: b^
Stack:
(a >NUM)' (b >NUM)' -> NUM'
Bitwise XOR.
CMD: b<<
Stack:
(a >NUM)' (b >NUM)' -> NUM'
Bitwise LSHIFT.
CMD: b>>
Stack:
(a >NUM)' (b >NUM)' -> NUM'
Bitwise RSHIFT.
CMD: b>>>
Stack:
(a >NUM)' (b >NUM)' -> NUM'
Bitwise unsigned RSHIFT.
CMD: :
Stack:
a i' -> (a._ | UN)'
Value at atomic index i in a.
CMD: :r
Stack:
a -> a._
Value at random index in a.
CMD: :`
Stack:
a i -> a._ | UN
Value at index i in a.
CMD: :*
Stack:
a (i >SEQ) -> _
:` with i mapped over a.
CMD: :/
Stack:
a (i >SEQ) -> _
:` with i folded over a.
CMD: :=
Stack:
a b i -> _
Sets value at index i in a to b.
CMD: :*=
Stack:
a (m >MAP) -> _
:= with i mapped over a.
CMD: :/=
Stack:
a b (i >SEQ) -> _
:= with i folded over a.
CMD: :%
Stack:
a (f >FN) i -> _
Modifies value at index i using f.
CMD: :*%
Stack:
a (m >MAP[(_ => (_ >FN))*]) -> _
:% with i mapped over a.
CMD: :/%
Stack:
a (f >FN) (i >SEQ) -> _
:% with i folded over a.
CMD: :-
Stack:
a i -> _
Removes index i from a.
CMD: :?
Stack:
a b' -> TF'
Whether a has atomic b.
CMD: :?`
Stack:
a b -> TF
Whether a has b.
MAPs check b against keys; other types of a check b against values.
CMD: len
Stack:
a -> NUM
Length of a.
CMD: ~len
Stack:
(a >OBS) -> TASK[NUM]
OBS-specific len.
CMD: shape
Stack:
a -> ARR[NUM*]
Shape of a, i.e. len of each dimension of a.
Determined by first element of each dimension.
CMD: shape^
Stack:
a -> ARR[NUM*]
shape but recursively maximizes lengths and depth instead of just using
the first element.
CMD: rank
Stack:
a -> NUM
CMD: rank^
Stack:
a -> NUM
CMD: ,
Stack:
a b -> ARR[a b]
Pairs a and b in an ARR.
CMD: ,,
Stack:
a -> ARR[a]
Wraps a in an ARR.
CMD: ,'
Stack:
a' b' -> ARR[a b]'
Vectorized ,.
CMD: ,,'
Stack:
a' -> ARR[a]'
Vectorized ,,.
CMD: ,`
Stack:
a* -> a
Wraps stack in an ARR.
CMD: ,_
Stack:
a -> a*
Unwraps a.
CMD: ,,_
Stack:
_* a -> a*
Replaces stack with a unwrapped.
CMD: tk
Stack:
a (n >NUM)' -> _
Takes up to n items from a.
Negative n takes from the end instead of the start.
CMD: ~tk
Stack:
(a >OBS) (n >NUM)' -> OBS
Emits a for n milliseconds.
CMD: ~tk`
Stack:
(a >OBS) (b >OBS) -> OBS
Emits a until b completes.
CMD: dp
Stack:
a (n >NUM)' -> _
Drops up to n items from a.
Negative n drops from the end instead of the start.
CMD: ~dp
Stack:
(a >OBS) (b >OBS) -> OBS
Discards emissions of a for n milliseconds.
CMD: ~dp`
Stack:
(a >OBS) (b >OBS) -> OBS
Discards emissions of a until b completes.
CMD: flat
Stack:
a -> _
Flattens a by one depth.
CMD: ~flat
Stack:
(a >OBS) -> OBS
OBS-friendly flat.
CMD: rflat
Stack:
a -> _
Flattens a recursively.
CMD: rep
Stack:
a -> SEQ
Infinite SEQ with a repeated.
5rep 10tk >A
-> [5 5 5 5 5 5 5 5 5 5]
[1 2 3] rep 10tk >A
-> [[1 2 3] [1 2 3] [1 2 3] [1 2 3] [1 2 3] [1 2 3] [1 2 3] [1 2 3] [1 2 3] [1 2 3]]
CMD: ~rep
Stack:
a -> OBS
OBS-specific rep.
CMD: cyc
Stack:
a -> SEQ
Infinite SEQ with elements of a cycled.
[1 2 3] cyc 10tk >A
-> [1 2 3 1 2 3 1 2 3 1]
CMD: ~cyc
Stack:
a -> OBS
OBS-specific cyc.
CMD: I*
Stack:
(a >NUM)' -> ARR[1*]'
Length-a ARR of 1's.
10I*
-> [1 1 1 1 1 1 1 1 1 1]
CMD: I^
Stack:
(a >ARR) -> ARR
ARR of 1's with dimensions a.
[2 3 4] I^
-> [[[1 1 1 1] [1 1 1 1] [1 1 1 1]] [[1 1 1 1] [1 1 1 1] [1 1 1 1]]]
CMD: mold
Stack:
a b -> _
Convert the shape of a to the shape of b.
$W [2 3 4] I^ mold
-> [[[0 1 2 3] [4 5 6 7] [8 9 10 11]] [[12 13 14 15] [16 17 18 19] [20 21 22 23]]]
$W [1 2 3] I* mold
-> [[0] [1 2] [3 4 5]]
CMD: itr
Stack:
a (f: b -> _)' -> SEQ'
Infinite SEQ of f successively Qed to a.
1 1.+ itr 10tk >A
-> [1 2 3 4 5 6 7 8 9 10]
1 ( 1+ 1 swap / ) itr 10tk >A
-> [1 1/2 2/3 3/5 5/8 8/13 13/21 21/34 34/55 55/89]
CMD: ~itr
Stack:
a (f: x -> >TASK)' -> OBS'
OBS-specific itr.
CMD: fold_
Stack:
a (f: b -> _ _ | ) -> SEQ
SEQ generated from f successively Qed to a, where x is the new
current item and y is the next b to be subsequently Qed to f.
Generation stops if f Qed to a results in an empty stack.
0 1, ( ,_ tuck + dups \swap dip ) fold_ 10tk >A
-> [1 1 2 3 5 8 13 21 34 55]
CMD: ~fold_
Stack:
a (f: b -> >TASK[ARR[_ _ | ]] ) -> OBS
OBS-specific fold_.
Note that unlike in fold_, f should return an ARR which acts in place
of the "stack".
CMD: >kv
Stack:
a -> [ARR[k v]*]
Key-value pairs of a.
["a" "b" "c" "d"] >kv >A
-> [[0 "a"] [1 "b"] [2 "c"] [3 "d"]]
["x""a", "y""b", "z""c", ]: >kv >A
-> [["x" "a"] ["y" "b"] ["z" "c"]]
CMD: =>kv
Stack:
a -> MAP
["a" "b" "c" "d"] =>kv
-> [0=>"a" 1=>"b" 2=>"c" 3=>"d"]:
CMD: >k
Stack:
a -> SEQ | ARR
Keys in a.
["x" "a", "y" "b", "z" "c", ]: >k >A
-> ["x" "y" "z"]
CMD: >v
Stack:
a -> SEQ | ARR
Values in a.
["x""a", "y""b", "z""c", ]: >v >A
-> ["a" "b" "c"]
CMD: a>b
Stack:
(a >NUM)' (b >NUM)' -> ARR[NUM*]'
Exclusive range from a to b.
CMD: a-b
Stack:
(a >NUM)' (b >NUM)' -> ARR[NUM*]'
Inclusive range from a to b.
CMD: O>a
Stack:
(a >NUM)' -> ARR[NUM*]'
Exclusive range from 0 to a.
CMD: O-a
Stack:
(a >NUM)' -> ARR[NUM*]'
Inclusive range from 0 to a.
CMD: a>O
Stack:
(a >NUM)' -> ARR[NUM*]'
Exclusive range from a to 0.
CMD: a-O
Stack:
(a >NUM)' -> ARR[NUM*]'
Inclusive range from a to 0.
CMD: I>a
Stack:
(a >NUM)' -> ARR[NUM*]'
Exclusive range from 1 to a.
CMD: I-a
Stack:
(a >NUM)' -> ARR[NUM*]'
Inclusive range from 1 to a.
CMD: a>I
Stack:
(a >NUM)' -> ARR[NUM*]'
Exclusive range from a to 1.
CMD: a-I
Stack:
(a >NUM)' -> ARR[NUM*]'
Inclusive range from a to 1.
CMD: shuf
Stack:
a -> _
Shuffles a.
10O>a shuf
-> [7 0 8 5 3 6 1 2 9 4]
CMD: perm
Stack:
a -> SEQ
All permutations of a.
[1 2 3] perm >A
-> [[1 2 3] [1 3 2] [2 1 3] [2 3 1] [3 1 2] [3 2 1]]
CMD: comb
Stack:
a (n >NUM)' -> SEQ'
All length-n combinations of a.
[1 2 3] 2comb >A
-> [[1 2] [1 3] [2 3]]
CMD: ^set
Stack:
a -> SEQ
All subsets of a.
[1 2 3] ^set >A
-> [[] [1] [2] [3] [1 2] [1 3] [2 3] [1 2 3]]
CMD: Q*
Stack:
a[_*] -> SEQ'
Cartesian product of iterable-of-iterables a to n.
["abc" "def" "ghi"] Q* >A
-> ["adg" "adh" "adi" "aeg" "aeh" "aei" "afg" "afh" "afi" "bdg" "bdh" "bdi" "beg" "beh" "bei" "bfg" "bfh" "bfi" "cdg" "cdh" "cdi" "ceg" "ceh" "cei" "cfg" "cfh" "cfi"]
CMD: tpose
Stack:
a[_*] -> [_*]
Transposes a collection of collections matrix-style. Safe for infinite lists.
[[1 2 3][4 5 6][7 8 9]] tpose
-> [[1 4 7] [2 5 8] [3 6 9]]
[[1 2][3 4 5][6]] tpose
-> [[1 3 6] [2 4] [5]]
CMD: raxes
Stack:
a[_*] -> [_*]
Reverses axes of an N-dimensional collection.
CMD: paxes
Stack:
a[_*] (b >ARR[NUM*]) -> [_*]
Permute axes of an N-dimensional collection using b.
CMD: pad
Stack:
(a >STR)' (b >NUM)' (c >STR)' -> STR'
Atomic pad`.
CMD: padl
Stack:
(a >STR)' (b >NUM)' (c >STR)' -> STR'
Atomic padl`.
CMD: padc
Stack:
(a >STR)' (b >NUM)' (c >STR)' -> STR'
Atomic padc`.
CMD: pad`
Stack:
a[_*] (b >NUM)' c -> STR'
Pads a from the right to length b using c.
[1 2 3 4] 9 0pad`
-> [1 2 3 4 0 0 0 0 0]
[1 2 3 4] 9 [5 6 7] pad`
-> [1 2 3 4 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7]
[1 2 3 4] 3 0pad`
-> [1 2 3 4]
CMD: padl`
Stack:
a[_*] (b >NUM)' c -> STR'
Pads a from the left to length b using c.
[1 2 3 4] 9 0padl`
-> [0 0 0 0 0 1 2 3 4]
[1 2 3 4] 9 [5 6 7] padl`
-> [5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 1 2 3 4]
[1 2 3 4] 3 0padl`
-> [1 2 3 4]
CMD: padc`
Stack:
a[_*] (b >NUM)' c -> STR'
Pads a from the outsides to length b using c.
[1 2 3 4] 9 0padc`
-> [0 0 1 2 3 4 0 0 0]
[1 2 3 4] 9 [5 6 7] padc`
-> [5 6 7 5 6 7 1 2 3 4 5 6 7 5 6 7 5 6 7]
[1 2 3 4] 3 0padc`
-> [1 2 3 4]
CMD: S>c
Stack:
(a >STR)' -> ARR[NUM*]'
Converts a to codepoints.
"hello"S>c
-> [104 101 108 108 111]
CMD: c>S
Stack:
(a >ARR[NUM*]) -> STR
Converts iterable of codepoints to STR.
[104 101 108 108 111] c>S
-> "hello"
CMD: <>
Stack:
(a >STR)' (b >STR)' -> ARR'
Splits a with b.
CMD: <>:
Stack:
a (i >NUM) -> ARR[_ _]
CMD: c<>
Stack:
(a >STR)' -> ARR'
<>s with empty string.
CMD: w<>
Stack:
(a >STR)' -> ARR'
<>s with space.
CMD: n<>
Stack:
(a >STR)' -> ARR'
<>s with newline.
CMD: s<>
Stack:
(a >STR)' -> ARR'
<>s on whitespace characters.
CMD: ><
Stack:
a (b >STR)' -> STR'
Joins a with b.
CMD: c><
Stack:
a -> STR'
><s with empty string.
CMD: w><
Stack:
a -> STR'
><s with space.
CMD: n><
Stack:
a -> STR'
><s with newline.
CMD: A>a
Stack:
(a >STR)' -> STR'
Converts STR to lowercase.
CMD: a>A
Stack:
(a >STR)' -> STR'
Converts STR to UPPERCASE.
CMD: >Aa
Stack:
(a >STR)' -> STR'
Converts STR to Capitalized.
CMD: /?
Stack:
(a >STR)' (r >STR)' -> SEQ[MAP]'
Matches a with regex r.
Each match returned is a MAP with the following keys:
-
&: MatchedSTR. -
`:STRbefore the match. -
':STRafter the match. -
*:ARR[MAP*]of each capturing group matched. -
^:NUMindex of the match's start. -
$:NUMindex of the match's end.
CMD: /?&
Stack:
(a >STR)' (r >STR)' -> SEQ[STR]'
/? with only & keys.
CMD: /?`
Stack:
(a >STR)' (r >STR)' -> SEQ[STR]'
/? with only ' keys.
CMD: /?'
Stack:
(a >STR)' (r >STR)' -> SEQ[STR]'
/? with only ` keys.
CMD: /?*
Stack:
(a >STR)' (r >STR)' -> SEQ[ARR[MAP*]]'
/? with only * keys.
CMD: /?^
Stack:
(a >STR)' (b >STR)' -> SEQ[NUM]'
/? with only ^ keys.
CMD: /?$
Stack:
(a >STR)' (b >STR)' -> SEQ[NUM]'
/? with only $ keys.
CMD: /#
Stack:
(a >STR)' (r >STR)' (f: MAP -> >STR)' -> STR'
Replace matches of regex r on a by applying each match MAP to f.
CMD: /#^
Stack:
(a >STR)' (r >STR)' (s >STR)' -> STR'
Replace first match of regex r on a with s.
CMD: map
Stack:
(a MAP) (f: k v -> _)' -> _'a (f: x -> _)' -> _'
Qs f on each element of a.
[1 2 3 4] 1.+ map
-> [2 3 4 5]
[0 1, 2 3, 4 5, ]: ( over + ) map
-> [0=>1 2=>5 4=>9]:
CMD: ~map
Stack:
(a >OBS) (f: x -> >TASK)' -> OBS'
OBS-specific map.
CMD: ~map||
Stack:
(a >OBS) (f: x -> >TASK)' (n >NUM)' -> OBS[ARR]'
~map that executes n tasks in parallel; both effects and results are
unordered.
CMD: ~map||>
Stack:
(a >OBS) (f: x -> >TASK)' (n >NUM)' -> OBS[ARR]'
~map|| but results are ordered.
CMD: tap
Stack:
a (f: k v -> )' -> a'a (f: x -> )' -> a'
map but a is preserved (i.e. leaving only side effects of f).
[1 2 3 4] ( 1+ n>o ) tap
-> [1 2 3 4]
2
3
4
5
CMD: each
Stack:
(a MAP) (f: k v -> )' -> UN'(a OBS) (f: x -> )' -> FUT[UN]'a (f: x -> )' -> UN'
tap that forces computation of a (e.g. with SEQ or OBS).
[1 2 3 4] ( 1+ n>o ) tap
-> [1 2 3 4]
2
3
4
5
CMD: mapf
Stack:
(a MAP) (f: k v -> >A)' -> _'a (f: x -> _)' -> _'
map and flatten results based on a's type.
1224P/ \*` mapf
-> [2 2 2 3 3 17]
CMD: ~mapf
Stack:
(a >OBS) (f: x -> >OBS)' -> OBS
OBS-specific mapf. Unlike mapf, ~mapf is non-deterministic;
execution occurs concurrently, and results are unordered.
CMD: ~mapf~
Stack:
(a >OBS) (f: x -> >OBS)' -> OBS
~mapf that only keeps the first result.
CMD: %map
Stack:
a f' (n >NUM)' -> _'
n-wise reduction of f over a.
[1 2 3 4] \+ 2%map
-> [3 5 7]
CMD: zip
Stack:
a b (f: x y -> _)' -> _'
Qs f over each element-wise pair of a and b.
Iterables of differing length truncate to the shorter length when zipped.
[1 2 3 4] [2 3 4 5] \, zip
-> [[1 2] [2 3] [3 4] [4 5]]
[1 2 3 4] [2 3] \+ zip
-> [3 5]
[1 2 3 4] [1 "a", 3 "b", "x" "c", ]: \, zip
-> [[1 [1 "a"]] [2 [3 "b"]] [3 ["x" "c"]]]
CMD: zip~
Stack:
a b c d (f: x y -> _)' -> _'
zip but instead of truncating,
uses c and d as fill elements for a and b respectively.
[1 2 3 4] [2 3 4 5] UN UN \, zip~
-> [[1 2] [2 3] [3 4] [4 5]]
[1 2 3 4] [2 3] UN UN \+ zip~
-> [3 5 3 4]
[1 2 3 4] [1 "a", 3 "b", "x" "c", ]: UN UN \, zip~
-> [[1 [1 "a"]] [2 [3 "b"]] [3 ["x" "c"]] [4 UN]]
CMD: tbl
Stack:
a b (f: x y -> _)' -> _'
Qs f over each table-wise pair of a and b.
[1 2 3 4] [2 3 4 5] \++ tbl
-> [["12" "13" "14" "15"] ["22" "23" "24" "25"] ["32" "33" "34" "35"] ["42" "43" "44" "45"]]
CMD: tblf
Stack:
a b (f: x y -> _)' -> _'
CMD: rmap
Stack:
a (f: x -> _)' -> _'
Atomic/recursive map.
[[1 2] 3 4 [5 [6 7]]] ( dup f>o ) rmap
-> [[1 2] 3 4 [5 [6 7]]]
1
2
3
4
5
6
7
CMD: dmap
Stack:
a (f: x -> _)' (n >NUM)' -> _'
map at depth n.
- If
n > 0, then depth is calculated outer-to-inner. - If
n = 0, then behavior is identical tormap. - If
n < 0, then depth is calculated inner-to-outer.
[[1 2] 3 4 [5 [6 7]]] ( dup f>o ) 2dmap
-> [[1 2] 3 4 [5 [6 7]]]
1
2
3
4
5
[6 7]
[[1 2] 3 4 [5 [6 7]]] ( dup f>o ) 1_ dmap
-> [[1 2] 3 4 [5 [6 7]]]
[1 2]
3
4
5
[6 7]
CMD: fold
Stack:
(a MAP) b (f: k x v -> _)' -> _'a b (f: x y -> _)' -> _'
Qs f to combine accumulator and each element starting from initial accumulator b.
[1 2 3 4] 0 \+ fold
-> 10
"1011"_` =>kv 0 ( rot 2 swap ^ * + ) fold
-> 0
CMD: ~fold
Stack:
(a >OBS) b (f: x y -> _) -> TASK
OBS-specific fold.
CMD: foldr
Stack:
(a MAP) b (f: k v x -> _)' -> _'a b (f: y x -> _)' -> _'
fold from the right.
CMD: rfold
Stack:
a b (f: x y -> _)' -> _'
Atomic/recursive fold.
[[1 2] 3 4 [5 [6 7]]] 0 \+ rfold
-> 28
[[1 2] 3 4 [5 [6 7]]] [] \+` rfold
-> [1 2 3 4 5 6 7]
CMD: rfoldr
Stack:
a b (f: y x -> _)' -> _'
rfold from the right.
CMD: fold~
Stack:
(a MAP) (f: k x v -> _)' -> _'a (f: x y -> _)' -> _'
fold without initial accumulator, instead using the first element of a.
If a is empty, then an error is thrown.
[1 2 3 4] \+ fold~
-> 10
[1 5 10 4 3] \| fold~
-> 10
CMD: foldr~
Stack:
(a MAP) (f: k v x -> _)' -> _'a (f: y x -> _)' -> _'
fold~ from the right.
CMD: scan
Stack:
(a MAP) (f: k x v -> _)' -> _'a b (f: x y -> _)' -> _'
fold with intermediate values.
[1 2 3 4] 0 \+ scan
-> [0 1 3 6 10]
CMD: ~scan
Stack:
(a >OBS) (b >TASK) (f: x y -> >TASK) -> OBS
OBS-specific scan.
CMD: scanr
Stack:
(a MAP) (f: k v x -> _)' -> _'a b f' -> _'
scan from the right.
CMD: +/
Stack:
a -> NUM
Sum of a. Equivalent to 0 \+ rfold.
CMD: */
Stack:
a -> NUM
Product of a. Equivalent to 1 \* rfold.
CMD: &/
Stack:
a -> _
Minimum of a. Equivalent to \&` fold~.
CMD: |/
Stack:
a -> _
Maximum of a. Equivalent to \|` fold~.
CMD: walk
Stack:
a f' -> _'
A multi-purpose function for creating, modifying, and traversing nested structures.
[[1 2] 3 4 [ "a" 5, "b" [6 7] , ]: ] ( dups f>o ) walk
-> [[1 2] 3 4 ["a"=>5 "b"=>[6 7]]:]
[[[1 2] 3 4 ["a"=>5 "b"=>[6 7]]:]]
[[1 2]]
[1]
[2]
[3]
[4]
[["a"=>5 "b"=>[6 7]]:]
["a" 5]
["b" [6 7]]
[6]
[7]
[[1 2] 3 4 [ "a" 5, "b" [6 7] , ]: ] ( dup len 0> ( dup +` ) &# ) walk
-> [[1 2 1 2] 3 4 ["a"=>5 "b"=>[6 7 6 7]]: [1 2 1 2] 3 4 ["a"=>5 "b"=>[6 7 6 7]]:]
CMD: fltr
Stack:
(a MAP) (f: k v -> >TF)' -> _'a (f: x -> >TF)' -> _'
Keeps elements of a that satisfy predicate f.
[5 1 2 4 3] 2.> fltr
-> [5 4 3]
CMD: ~fltr
Stack:
(a >OBS) (f: x -> >TASK[TF]) -> OBS
OBS-specific fltr.
CMD: any
Stack:
(a MAP) (f: k v -> >TF)' -> TF'a (f: x -> >TF)' -> TF'
Whether any elements of a satisfy predicate f.
[5 1 2 4 3] 2.> any
-> $T
CMD: ~any
Stack:
(a >OBS) (f: x -> >TASK[TF]) -> TASK[TF]
OBS-specific any.
CMD: all
Stack:
(a MAP) (f: k v -> >TF)' -> TF'a (f: x -> >TF)' -> TF'
Whether all elements of a satisfy predicate f.
[5 1 2 4 3] 2.> all
-> $F
CMD: ~all
Stack:
(a >OBS) (f: x -> >TASK[TF]) -> TASK[TF]
OBS-specific all.
CMD: tk*
Stack:
(a MAP) (f: k v -> >TF)' -> _'a (f: x -> >TF)' -> _'
Takes elements of a until Qing f is falsy.
[5 1 2 4 3] 4.!= tk*
-> [5 1 2]
CMD: dp*
Stack:
(a MAP) (f: k v -> >TF)' -> _'a (f: x -> >TF)' -> _'
Drops elements of a while predicate f is truthy.
[5 1 2 4 3] 4.!= dp*
-> [4 3]
CMD: find
Stack:
(a MAP) (f: k v -> >TF)' -> _'a (f: x -> >TF)' -> _'
Finds first element of a where predicate f is truthy.
Returns UN if not found.
[5 1 2 4 3] ( 2% ! ) find
-> 2
CMD: ~find
Stack:
(a >OBS) (f: x -> >TASK[TF]) -> TASK
OBS-specific find.
CMD: find:
Stack:
(a MAP) (f: k v -> >TF)' -> NUM'a (f: x -> >TF)' -> NUM'
Finds index of first element of a where predicate f is truthy.
Returns -1 if not found.
[5 1 2 4 3] ( 2% ! ) find:
-> 2
CMD: del
Stack:
(a MAP) (f: k v -> >TF)' -> _'a (f: x -> >TF)' -> _'
Deletes first element of a where predicate f is truthy.
[5 1 2 4 3] ( 2% ! ) del
-> [1 2 4 3]
CMD: uniq
Stack:
(a MAP) (f: k v -> _)' -> _'a (f: x -> _)' -> _'
Uniquifies elements of a with mapper f.
[2 4 3 3 5 4 1] () uniq
-> [2 4 3 5 1]
[5 1 2 4 3] 2.% uniq
-> [5 2]
CMD: uniq~
Stack:
(a MAP) (f: ARR[k v] ARR[j w] -> >TF)' -> _'a (f: x y -> >TF)' -> _'
Uniquifies elements of a with equality predicate f.
[2 4 3 3 5 4 1] \=` uniq~
-> [2 4 3 5 1]
[2 4 3 3 5 4 1] 2.% uniq~
-> [2 4 3]
CMD: sort
Stack:
(a MAP) (f: k v -> _)' -> _'a (f: x -> _)' -> _'
Sorts elements of a with mapper f.
["a" "" "abc" "ab"] \len sort
-> ["" "a" "ab" "abc"]
[1 2 3 4 5] \$rng sort
-> [1 5 4 3 2]
CMD: sort~
Stack:
(a MAP) (f: ARR[k v] ARR[j w] -> >NUM)' -> _'a (f: x y -> >NUM)' -> _'
Sorts elements of a with comparator f.
[1 5 2 3 4] \< sort~
-> [1 2 3 4 5]
[1 5 2 3 4] \> sort~
-> [5 4 3 2 1]
CMD: part
Stack:
(a MAP) (f: k v -> >TF)' -> ARR[_ _]'a (f: x -> >TF)' -> ARR[_ _]'
Separates a into 2 parts based on predicate f.
[5 1 2 4 3] 2.> part
-> [[5 4 3] [1 2]]
CMD: group
Stack:
(a MAP) (f: k v -> _)' -> MAP'a (f: x -> _)' -> MAP'
Separates a groups based on f.
Each result of f becomes a key in the resulting MAP.
"abc"^set >A \len group
-> [0=>[""] 2=>["ab" "ac" "bc"] 1=>["a" "b" "c"] 3=>["abc"]]:
CMD: ~group
Stack:
(a >OBS) (f: x -> _)' -> OBS[ARR[_ _]*]'
OBS-specific group.
CMD: span
Stack:
(a MAP) (f: k v -> >TF)' -> ARR[_ _]'a (f: x -> >TF)' -> ARR[_ _]'
Equivalent to a combination of tk* and dp*.
[5 1 2 4 3] 2.% span
-> [[5 1] [2 4 3]]
CMD: pack
Stack:
(a MAP) (f: ARR[k v] ARR[j w] -> >TF)' -> _'a (f: x y -> >TF)' -> _'
Groups consecutive duplicate runs of a based on predicate f.
[1 1 2 3 3 4 6 4 4] \=` pack
-> [[1 1] [2] [3 3] [4] [6] [4 4]]
CMD: union
Stack:
a b (f: x y -> >TF)' -> _'
Gets the union of a and b with equality predicate f.
[1 2 3 4] [2 4 6 8] \=` union
-> [1 2 3 4 6 8]
CMD: intxn
Stack:
a b (f: x y -> >TF)' -> _'
Gets the intersection between a and b with equality predicate f.
May hang if a or b are infinite.
See sort~ for the signature of f.
[1 2 3 4] [2 4 6 8] \=` intxn
-> [2 4]
CMD: diff
Stack:
a b (f: x y -> >TF)' -> _'
Gets the difference between a and b with equality predicate f.
Will hang if b is infinite.
See sort~ for the signature of f.
[1 2 3 4] [2 4 6 8] \=` diff
-> [1 3]
CMD: ~_
Stack:
(a >FUT[x])' -> x'
Synchronously waits for a to complete, leaving the result on the stack.
CMD: ~$
Stack:
(a >FUT)' ->
Cancels a.
CMD: ~^
Stack:
(a OBS) -> OBS(a >TASK)' -> TASK
Inserts an asynchronous boundary.
CMD: ~^`
Stack:
(a >OBS) (b >OSTRAT)' -> OBS'
OBS-specific ~^ that uses b to determine overflow strategy.
CMD: ~|>
Stack:
a[>TASK*] -> TASK[[_*]]
Executes each TASK in a sequentially such that both effects and results
are ordered.
CMD: ~||
Stack:
a[>TASK*] -> TASK[[_*]]
Executes each TASK in a in parallel such that effects are unordered but
results are ordered.
CMD: ~||>
Stack:
a[>TASK*] (n >NUM) -> TASK[[_*]]
~|| but with at most n concurrently running TASKs.
CMD: ~//
Stack:
a[>TASK*] -> TASK[[_*]]
~|| but results are also unordered.
CMD: ~>>
Stack:
a[>TASK*] -> TASK
Races a collection of TASKs, returning the first to complete.
CMD: ~<
Stack:
(a >TASK)' -> TASK'
Ensures that a runs on a separate thread.
CMD: ~io
Stack:
(a >TASK)' -> TASK'
Ensures that a runs on a thread-pool for blocking I/O.
CMD: ~memo
Stack:
(a OBS) -> OBS(a >TASK)' -> TASK'
Ensures that a is memoized such that subsequent runs return the same
value.
CMD: ~memo&
Stack:
(a >TASK)' -> TASK'
~memo but only if a completes successfully.
CMD: ~memo`
Stack:
(a >OBS) (n >NUM)' -> OBS'
Caches emissions of a with maximum cache capacity n.
CMD: ~$_
Stack:
(a OBS) -> OBS(a >TASK)' -> TASK'
Ensures that a is uncancellable.
CMD: ~%
Stack:
(a >TASK)' (ms >NUM)' -> TASK'
Ensures that a will error if not completed within ms milliseconds.
CMD: ~%Q
Stack:
(a >TASK)' -> TASK[ARR[NUM _]]'
Times the execution of a, yielding the execution time (in ms) and the
result.
CMD: ~?
Stack:
(a >TASK)' (f: ERR -> >TASK)' (g: x -> >TASK)' -> TASK'
If a errors, then f is called with the error, providing an opportunity
to recover.
Otherwise, g is called with the result.
CMD: ~@
Stack:
(a OBS) (f: x -> >TF)' -> OBS'(a >TASK)' (f: x -> >TF)' -> TASK'
Continually retries a until f is truthy.
CMD: ~%@
Stack:
(ms >NUM)' -> OBS'
Creates an OBS that emits whole numbers at a fixed rate of ms
milliseconds.
CMD: ~+%@
Stack:
(ms >NUM)' -> OBS'
Creates an OBS that emits whole numbers with delays of ms milliseconds.
CMD: ~!?
Stack:
(a >TASK[x])' -> TASK[TRY[x]]'
Wraps the contents of a in a TRY.
CMD: ~!?_
Stack:
(a >TASK[TRY[x]])' -> TASK[x]'
Unwraps a TRY inside a.
CMD: ~?[]
Stack:
(a OBS) (f: x -> >OBS)' (g: y (e (TF | ERR)) -> >TASK)' -> OBS'(a >TASK) (f: x -> >TASK)' (g: y (e (TF | ERR)) -> >TASK)' -> TASK'
Defines usage handler f and finalizer g for a.
Suited for safely using and cleaning up resources.
e is:
-
$Ton completion. -
ERRon error. -
$Fon cancellation.
CMD: ~?!>
Stack:
(a OBS) (f: (e ERR) -> >TASK)' -> OBS'(a >TASK) (f: (e ERR) -> >TASK)' -> TASK'
Transforms f when a errors.
CMD: ~sleep
Stack:
(ms >NUM)' -> TASK[ms]'
Creates an asynchronous TASK that completes after ms milliseconds.
CMD: ~delay
Stack:
(a OBS) (ms >NUM)' -> OBS'(a >TASK) (n >NUM)' -> TASK'
Delays the TASK for ms milliseconds.
CMD: ~delay`
Stack:
(a >OBS) (b >OBS) -> OBS
Delays a until b either emits or completes.
CMD: ~/n
Stack:
(a >OBS) (n >NUM)' -> OBS'
Buffers up to n elements when downstream is busy.
Back-pressures when buffer reaches n.
CMD: ~/%
Stack:
(a >OBS) (ms >NUM)' -> OBS'
Buffers elements within ms-millisecond timespans.
CMD: ~/%n
Stack:
(a >OBS) (ms >NUM)' (n >NUM)' -> OBS'
Combines ~/% and ~/n.
Force-emits instead of back-pressuring when buffer reaches n.
CMD: ~/%<
Stack:
(a >OBS) (ms >NUM)' (n >NUM)' (f: x -> >NUM)' -> OBS'
~/%n but with back-pressure instead of force-emitting.
Also uses f to determine weight of each element.
CMD: ~/n`
Stack:
(a >OBS) (b >OBS) (n >NUM)' -> OBS'
Buffers a until b emits.
Back-pressures when buffer reaches n.
CMD: ~>-<
Stack:
(a >OBS) (ms >NUM)' (n >NUM)' -> OBS[ARR]'
Limits a to n emissions every ms milliseconds.
CMD: ~>-^
Stack:
(a >OBS) (ms >NUM)' -> OBS[ARR]'
Keeps the first emission of a per ms-millisecond timespan.
CMD: ~>-$
Stack:
(a >OBS) (ms >NUM)' -> OBS[ARR]'
Keeps the last emission of a per ms-millisecond timespan.
CMD: ~>~-
Stack:
(a >OBS) (ms >NUM)' -> OBS'
Debounces a such that emissions only occur after ms milliseconds without
emission.
CMD: ~^UN
Stack:
-> OSTRAT
Specifies that the buffer is unbounded. May exhaust system memory with fast data sources.
CMD: ~^ERR
Stack:
(n >NUM)' -> OSTRAT
Specifies that when the buffer reaches n, subscription is canceled with an
error.
CMD: ~^BAK
Stack:
(n >NUM)' -> OSTRAT
Specifies that when the buffer reaches n, back-pressure is applied.
CMD: ~^NEW
Stack:
(n >NUM)' -> OSTRAT
Specifies that when the buffer reaches n, new elements are dropped.
CMD: ~^OLD
Stack:
(n >NUM)' -> OSTRAT
Specifies that when the buffer reaches n, old elements are dropped.
CMD: ~^CLR
Stack:
(n >NUM)' -> OSTRAT
Specifies that when the buffer reaches n, buffer is cleared.
CMD: _/<>
Stack:
a -> ARR
Gets filepath a in segments.
CMD: _/><
Stack:
a -> STR
Gets filepath a as a string.
CMD: _/x
Stack:
a -> STR
Gets the filename of filepath a.
CMD: _/x_
Stack:
a -> STR
Gets the basename of filepath a.
CMD: _/_x
Stack:
a -> STR
Gets the file extension of filepath a.
CMD: S>b
Stack:
(a >STR) -> STR
Converts a from UTF-8 to ISO-5589-1.
CMD: b>S
Stack:
(a >STR) -> STR
Converts a from ISO-5589-1 to UTF-8.
CMD: ~S>b
Stack:
(a >STR) -> STR
OBS-friendly S>b.
CMD: ~b>S
Stack:
(a >STR) -> STR
OBS-friendly b>S.
CMD: fs>
Stack:
a -> OBS[STR*]
Streams contents of filepath a as UTF-8.
CMD: fs>b
Stack:
a -> OBS[STR*]
Streams contents of filepath a as bytes.
If you know that a only contains codepoints 0-255,
then this is a faster option than fs>.
CMD: fs>n
Stack:
a (b >STR) -> OBS[STR*]
Streams lines of filepath a with encoding b.
b defaults to UTF-8 when empty.
CMD: >fs
Stack:
(a >OBS[STR*]) b -> TASK[NUM]
Streams UTF-8 a to filepath b.
CMD: b>fs
Stack:
(a >OBS[STR*]) b -> TASK[NUM]
Streams bytes a to filepath b.
CMD: ^>fs
Stack:
(a >OBS[STR*]) b (n >NUM)' -> TASK[NUM]'
Streams UTF-8 a to filepath b starting at position n.
CMD: b^>fs
Stack:
(a >OBS[STR*]) b (n >NUM)' -> TASK[NUM]'
Streams bytes a to filepath b starting at position n.
CMD: fs@
Stack:
a -> OBS[MAP["t"=>NUM "f"=>NUM "s"=>STR]]'
Watches filepath a for changes.
-
tis the type; 1 for create, 2 for modify, and 3 for delete. -
nis the count; greater than 1 signifies that the event is repeated. -
fis the context, or the relative filepath that was changed.
CMD: fs:
Stack:
a -> OBS[STR*]
Lists files at path a.
CMD: fs::
Stack:
a -> OBS[STR*]
Recursively lists files at path a.
CMD: fs*
Stack:
a (b >STR)' -> OBS[STR*]'
Lists files at path a that match glob pattern b.
CMD: fs*?
Stack:
a (b >STR)' -> OBS[STR*]'
fs* but with regex b.
CMD: tcp>
Stack:
(a >STR)' (b >NUM)' -> OBS[STR*]'
Streams host a and port b over TCP as UTF-8.
CMD: tcp>b
Stack:
(a >STR)' (b >NUM)' -> OBS[STR*]'
Streams host a and port b over TCP as bytes.
CMD: >tcp
Stack:
(a >OBS[STR*]) (b >STR)' (c >NUM)' -> OBS[STR*]'
Streams UTF-8 a over TCP to host b and port c.
CMD: b>tcp
Stack:
(a >OBS[STR*]) (b >STR)' (c >NUM)' -> OBS[STR*]'
Streams bytes a over TCP to host b and port c.
Made with ❤️ by Ben Pang (@molarmanful).