This language reference was recovered and many bugfixes to it have been lost. If you notice any errors or if descriptions aren't clear enough please notify me. I want to keep this as accurate and complete as possible.
Builtin Types
The following builtin types exist:
- Int - Integer (UNBOUNDED!)
- Double - Double
- Str - String
- Char - Character
- Block - (Lists)
- Ident - Identifier
- Nil - Internal usage only
- Quoted - Can be used to push identifiers on the stack
- Error - Can not be written as a literal in code
- Pretty - Pretty print stuff
Builtins
deepmap means that the command automatically maps over blocks. deepzip means, that the command automatically zipsWith over blocks. deepfilter means that the command automatically filters blocks. (strings usually too). deepzip2 means, that the command automatically box cycles non block arguments if the other argument is a block and then deepzips.Name | Ident | Args | Description | |
Abs | ab | Int a Double a | Abs a | |
Add | .+ | Int a, Int b | Regular integer addition (a + b) | |
.+ | Double a, Double b | Addition (a + b) | ||
.+ | Double a, Int b | (a + b) | ||
.+ | Int a, Double b | (a + b) | ||
.+ | Str a, Str b | String concatenation (a ++ b) | ||
.+ | Block a, Block b | Block concatenation (a ++ b) | ||
.+ | Char a, Char b | Append chars to form a string | ||
.+ | Str a, Char b | Append char to string | ||
.+ | Int b, Str a Int b, Block a Str a,Int b Block a,Int b | Take b characters from a | ||
AddX | _+ | Int a, Int b | Returns a block with a and b | |
_+ | Double a, Double b | Returns a block with a and b | ||
_+ | Str a, Str b | String concatenation (a ++ b) | ||
_+ | Block a, Block b | Block concatenation (a ++ b) | ||
_+ | Char a, Char b | Append chars to form a string | ||
_+ | Str a, Char b Char a, Str b | Append char to string | ||
_+ | Str a, Int b Int a, Str b | Append int to string | ||
_+ | Block a, Any b | Append b to a | ||
All | al | Defined as m[r& | ||
AllAlpha | aa | Defined as {rd}m[al | ||
AllAlphaNum | an | Defined as {ri}m[al | ||
AllDigit | ad | Defined as {><}m[al | ||
And | && | Int a, Int b | Bitwise and | |
&& | deepzip2 (int) | |||
AndLs | r& | Defined as {&&}r[ | ||
Any | ay | Defined as m[r| | ||
Append | [+ | Block a, Any b Int a, Int b | Append b to a | |
[+ | Str a,Char b | Append b to a | ||
Apply | ap | Block f, Int idx, Block xs Int idx, Block f, Block xs | Applies f to the element in xs at index idx | |
ApplyRegex | ~a | String a, Block f, String regex | Apply the function f to every substring that matched the regex. "123b23"{<-}"[0-9]+"~a results in "321b32" | |
Average | av | Block a | Defined as ^^ ++ \/ L[ pd ./ | |
av | Double a | Floor a | ||
Average2 | AV | Defined as PDav | ||
Asin | TS | Double a Int a | asin | |
TS | deepmap | |||
Acos | TC | Double a Int a | acos | |
TC | deepmap | |||
Atan | TT | Double a Int a | atan | |
TT | deepmap | |||
BlockAccess | !! | Block a, Int n Str a, Int n | Return the nth element | |
Box | bx | Any a | Put a in an empty block | |
BoxCycle | bc | Defined as bxcy | ||
BoxSP | bs | Defined as bxsp | ||
BoxSP2 | BS | Defined as bxspsh | ||
BinomialDCumulative | Bc | Int n, Double prb, Double c | binomial distribution cumulative | |
BinomialDPropability | Bp | Int n, Double prb, Int nth | binomial distribution probability | |
Ceiling | cl | Defined as pdpd | ||
Choose | ch | Defined as \/n!!! | ||
ChooseWords | CW | Defined as wdch | ||
ChiSquaredDCumulative | cc | Int df, Double c | chisquared distribution cumulative | |
ChiSquaredDDensity | cd | Int df, Double c | chisquared distribution density | |
ChiSquaredDQuantile | cq | Int df, Double c | chisquared distribution quantile | |
ChiSquaredTest | ct | Defined as ^^x/?-2?^\/0.0?+?/++ | ||
ChunksOf | co | Block a, Int n Str a, Int n Int a, Int n | Split a into chunks of size n | |
Chunky | CO | Block a, Int n Str a, Int n Int a, Int n | Create n-grams. "abc"2CO is {"ab" "bc"} | |
CoolMap | M- | Defined as \/bxcy\/z[{p^+]e!}m[. Example: 2{{?i}{?d}}M- | ||
CoerceAdd | ?+ | Double a, Int b Int a, Double b | Defined as pd.+ | |
?+ | Str a, Int b Int a, Str b | Defined as Sh.+ | ||
?+ | Str a, Double b Double a, Str b | Defined as Sh.+ | ||
?+ | Block a, Int b Int a, Block b | Defined as bxcy?+ | ||
?+ | Block a, Double b Double a, Block b | Defined as bxcy?+ | ||
?+ | Block a, Str b Str a, Block b | Defined as bxcy?+ | ||
?+ | Block a, Block b | Defined as {^p?+}Z[ | ||
CoerceDiv | ?/ | Double a, Int b Int a, Double b | Defined as pd./ | |
?/ | Str a, Int b Int a, Str b | Defined as Sh./ | ||
?/ | Str a, Double b Double a, Str b | Defined as Sh./ | ||
?/ | Block a, Int b Int a, Block b | Defined as bxcy?/ | ||
?/ | Block a, Double b Double a, Block b | Defined as bxcy?/ | ||
?/ | Block a, Str b Str a, Block b | Defined as bxcy?/ | ||
?/ | Block a, Block b | Defined as {^p?/}Z[ | ||
CoerceFactorial | ?! | Int a | Defined as ropd | |
?! | Block a | Defined as {?!}m[ | ||
CoerceMul | ?* | Double a, Int b Int a, Double b | Defined as pd.* | |
?* | Str a, Int b Int a, Str b | Defined as Sh.* | ||
?* | Str a, Double b Double a, Str b | Defined as Sh.* | ||
?* | Block a, Int b Int a, Block b | Defined as bxcy?* | ||
?* | Block a, Double b Double a, Block b | Defined as bxcy?* | ||
?* | Block a, Str b Str a, Block b | Defined as bxcy?* | ||
?* | Block a, Block b | Defined as {^p?*}Z[ | ||
CoercePow | ?^ | Double a, Int b Int a, Double b | Defined as pd.* | |
?^ | Block a, Int b Int a, Block b | Defined as bxcy?* | ||
?^ | Block a, Double b Double a, Block b | Defined as bxcy?* | ||
?^ | Block a, Str b Str a, Block b | Defined as bxcy?* | ||
?^ | Block a, Block b | Defined as {^p?^}Z[ | ||
CoerceSub | ?- | Double a, Int b Int a, Double b | Defined as pd.- | |
?- | Str a, Int b Int a, Str b | Defined as Sh.- | ||
?- | Str a, Double b Double a, Str b | Defined as Sh.- | ||
?- | Block a, Int b Int a, Block b | Defined as bxcy?- | ||
?- | Block a, Double b Double a, Block b | Defined as bxcy?- | ||
?- | Block a, Str b Str a, Block b | Defined as bxcy?- | ||
?- | Block a, Block b | Defined as {^p?-}Z[ | ||
CoerceSqrt | ?s | Int a | Defined as pdr@ | |
?s | Block a | Defined as {?s}m[ | ||
CoerceInc | ?i | Double a | Defined as 1.0?+ | |
?i | Block a | Defined as {?i}m[ | ||
CoerceDec | ?d | Double a | Defined as 1.0?- | |
?d | Block a | Defined as {?d}m[ | ||
CollectStack | CL | Collects the whole stack in a Block and pushes the Block to the stack | ||
CollectStackReverse | Cl | Defined as CL<- | ||
Concat | \[ | a | Defined as {_+}r[ | |
ConcatMap | \m | Defined as m[\[ | ||
Contains | ~[ | Block a, Any b | Does a contain b? | |
~[ | Str a, Char b | Does a contain b? | ||
~[ | Int a, Int b | Does a contain the digits of b? | ||
~[ | Str a, Str b | Does a contain b? | ||
Cond | cn | Any a, Block conds | conds is a block with conditions at even indices and what happens at odd indices. I.e. 3 {{15.%n!} "FizzBuzz" {5.%n!} "Fizz" {3.%n!} "Buzz"}cn If no condition matches it returns a. | |
Continuation | c! | Block a | Continuation with a | |
ContinuationMany | C! | Block a, Int n | Runs the continuation a exactly n times | |
ContinuationManyReverse | !C | Defined as C!#< | ||
ConvertBase | B! | Int n, Int b | convert n to base b (result is a string) | |
B! | deepzip2 (int,string) | |||
B! | String n, Int b | Parse n as an number in base b (result is an int) | ||
ConvertBase2 | b2 | Defined as 2B! | ||
ConvertBase16 | b6 | Defined as 16B! | ||
ConvertBase10 | b0 | Defined as 10B! | ||
Combinations | CB | Block a, Int n Str a, Int n Int a, Int n | Generate a list of combinations of a of length n | |
CombinationsUpTo | cb | Block a, Int n Str a, Int n Int a, Int n | Generate a list of combinations of a up to length n | |
Compare | cm | Any a, Any b | Compare a with b (1 for greater, 0 for equal, -1 else) | |
Compare 2 | CM | Defined as
^^bx(\/)[+\/[+(\/)[+(cm)[+ Can be used to construct a comparison function for sortBy. (L[)CMsb sorts by length. It generates a block of the form {xx \/ xx \/ cm} where xx is the command passed as argument. | ||
Compare 3 | Cm | Defined as^^(\/)[+\/.+{\/cm}.+ Esentially it behaves the same as Compare 2 but takes a block with multiple commands. | ||
Cos | Tc | Double a Int a | cosinus | |
Tc | deepmap | |||
Check | ck | Defined as n!n! | ||
CrossProduct | cp | Block a, Block b Str a, Str b | Crossproduct (a x b) | |
Count | CN | Defined as: {*==}fl (where * is the argument supplied to CN) | ||
Cycle | cy | Block a Str a | Repeat a infinite times | |
cy | Int a | Convert to string and then cycle | ||
Decrement | -. | Int a | Decrement a-- | |
-. | Char a | Previous char (chr(ord(a)-1)) | ||
-. | Str a Block a | Prepend head of a to a | ||
DeleteIndices | di | Defined as (RA)\/[[(RA)[+e! | ||
DiffLs | \\ | Block a, Block b Str a,Str b Int a, Int b | List difference (a \\ b) | |
Digits | dg | Int n, Int b | Returns the digits of n base b. E.g. 14 3dg={1 1 2} | |
DimArrayAccess | d! | Defined as (!!)\/[[(!!)[+e! | ||
DimArraySet | D! | Block arr, Block adr, Any e | Sets the element in arr at position adr to e (see DimArrayAccess) | |
Div | ./ | Int a, Int b | Regular integer division (a / b) | |
./ | Double a, Double b | Division (a / b) | ||
./ | Double a, Int b | (a / b) | ||
./ | Int a, Double b | (a / b) | ||
./ | Str a,Str b | If a starts with b, remove b from a | ||
Divides | dv | Defined as .%n! | ||
DropWhile | dw | Block p Block ls | drop elements from ls as long as p holds true | |
dw | Block p Str s | Defined as **dw\[ | ||
DropWhileSwapped | DW | Defined as \/dw | ||
Dup | ^^ J | Duplicate top most element on the stack | ||
DupSwap | ^/ | Defined as ^^ \/ | ||
EmptyBlockToStr | es | Converts an empty block to an empty string. Else it does nothing | ||
Equal | == | Any a, Any b | Comparision (a == b) | |
Eval | e! | Block a | Eval a block | |
EvalMany | E! | Defined as .*\[e! | ||
EveryNth | en | Str a, Int n Block a, Int n Int a, Int n | Returns a block/str/int containing every nth element/char/digit | |
ExponentialDCumulative | ec | Double lambda, Double c | exponential distribution cumulative | |
ExponentialDDensity | ed | Double lambda, Double c | exponential distribution density | |
ExponentialDQuantile | eq | Double lambda, Double c | exponential distribution quantile | |
Factors | fc | Int a | Return a block with every number a is divisible by Order of the block returned is smallest first. | |
fc | Str a Block a | Least common element | ||
Filter | f[ | Block f, Str a Block f, Block a | Filters a list according to the predicate f (must return 1 or 0) | |
FilterFromOne | FO | Defined as \/1\/r@\/f[ | ||
FilterFromZero | FZ | Defined as \/0\/r@\/f[ | ||
FilterLength | fl | Defined as f[L[ | ||
FilterLines | W[ | Defined as \/ln\/f[un | ||
FilterMap | FM | Block f, Block m | Behaves as f FILTER m MAP ({f}f[{m}m[). | |
FilterWords | w[ | Defined as \/WD\/f[wd | ||
FilterWordsB | fw | Defined as f[wd | ||
FilterUnlines | fu | Defined as f[un | ||
FindIndex | fi | Block a, Block f Str a, Block f | Find index of element where f returns true. | |
FindIndexEq | Fi | Block a, Any p Str a, Char p | Find index of an element equal to p | |
FindIndices | fI | Block a, Block f Str a, Block f | Like FindIndex but does not stop on the first match but instead returns a list of indices. | |
FindElement | fe | Block a, Block f Str a, Block f | Find an element where f is true and return it | |
Flatten | FL | Block xs | Completely flatten xs | |
Floor | fo | Defined as avpd | ||
FlipBits | fp | Int a | Flip all bits in a | |
Format | FF | Pretty a, Int b | Changes the format of a according to b | |
FormatFromFormat | Ff | n/a | Defined as FF ff | |
FrequencyList | f: | Returns a Block of Blocks with {count element}. Counts how many times each element occurs in a list. Defined as sg{^^L[\/-]bx\/+]}m[<> | ||
FrequencyListPercentage | F: | Like FrequencyList but contains relative percentages. Defined as f:u[\/PD^^++?/\/z[ | ||
FromFormat | ff | Pretty a | Extracts the string out of the pretty | |
GenerateListO | GO | Defined as POP1\/R@PUSHm[ | ||
GenerateListZ | GZ | Defined as POP0\/R@PUSHm[ | ||
Geq | >= | Any a, Any b | a >= b | |
Gcd | g_ | Int a, Int b | gcd(a,b) | |
g_ | Block a Str a | Defined as ^^-]\/[-\/ | ||
Greater | .> | Any a, Any b | Comparision (a > b) | |
Grep | gr | Defined as {~=}\/+]\/ln\/f[un | ||
GeometricDCumulative | gc | Double succrate, Double c | shifted geometric distribution cumulative | |
GeometricDPropability | gp | Double succrate, Int nth | shifted geometric distribution probability | |
Group | =[ | Block a | Group (equal consecutive) elements in a | |
GroupBy | gb | Block xs, Block f Block str, Block f | Group by a comparison function f. | |
GroupBy2 | gB | Block xs, Block f Block str, Block f | Group by a function f where f takes one argument. {1 2 3 5 7 4 8 2 0}{3.>}gB yields {{1 2 3} {5 7 4 8} {2 0}} | |
GroupLength | gl | Defined as =[L[ | ||
GroupNub | gn | Defined as =[{-]}m[ | ||
GroupSort | gs | Defined as =[>< | ||
GroupWithLength | gw | Defined as =[{^^L[\/-]bx\/+]}m[ | ||
Head | -] | Block a Int a | First element | |
-] | Str a | First character | ||
HeadTail | -~ | Defined as -][- | ||
Hide | hd | Hide element and move to the bottom of the stack | ||
Hide2 | HD | Hide element but keep on top | ||
HyperGeometricDCumulative | hc | Int m, Int l, Int k, Double c | shifted hypergeometric distribution cumulative k elements, l population, m elements of one kind | |
HyperGeometricDPropability | hp | Int m, Int l, Int k, Int nth | shifted hypergeometric distribution probability | |
IsError | is | Return 1 on error 0 else | ||
IfElse | ie | Block a, Block b, Int c | If c then a else b | |
Iff | if | Block b, Int a | If a then execute b, else pop a and pop b | |
if | Int a, Block b | If a then execute b, else pop a and pop b | ||
Implode | im | Defined as {++}r[ | ||
Increment | +. | Int a | Increment (a++) | |
+. | Char a | Next char (chr(ord(a)+1)) | ||
+. | Str a Block a | Append last of a to a | ||
InfixOf | ~~ | Block a, Block b | Does a contain b (as a consecutive subsequence)? | |
Init | ~] | Block a Int a | All except the last element | |
~] | Str a | All except the last character | ||
~] | Int a | All except last digit | ||
Inits | iT | Str xs Block xs | Generates all inits. {1 2 3}iT results in {{} {1} {1 2} {1 2 3}} | |
InitTail | ~- | n/a | Defined as ~][- | |
Intercalate | ic | Defined as [[\[ | ||
IntercalateSwapped | IC | Defined as \/ic | ||
Intersection | IN | Block a, Block b Str a,Str b Int a, Int b | Intersection | |
Intersperse | [[ | Any a, Block b Char a,String b | Inserts a between every two element in b | |
IntersperseSwapped | [] | Defined as \/[[ | ||
InsertAt | ia | Str ls, Char e, Int idx Block ls, Any e, Int idx | Insert element e into ls at index idx | |
It | it | Removes everything from the stack except the element on the top. | ||
Last | [~ | Block a Int a | Last element of the block | |
Lcm | l_ | Int a, Int b | lcm(a,b) | |
l_ | Block a Str a | Defined as ^^-]\/[-\/ | ||
Length | L[ | Block a | Length of a | |
L[ | Str a | Length of a | ||
L[ | Int a | Convert to char (chr a) | ||
L[ | Char a | Return case of a as 'A or 'a | ||
Leq | <= | Any a, Any b | a <= b | |
LeftPad | lp | Defined as x/Shx/\/x/x/\/P[ | ||
Lines | ln | Str a | Splits a string into lines | |
ln | Int a | Number of digits in an integer | ||
Load | ld | Int n | Load the nth hidden element from the bottom of the stack (put on top) | |
Load2 | LD | Defined as lde! | ||
Log | lg | Double a Int a | log(a) (natural logarithm) | |
Log2 | LG | Defined as lg\/lg./ | ||
LogBase2 | l2 | Defined as 2\/LG. | ||
LogBase10 | l0 | Defined as 10\/LG. | ||
Loop | LO | Not much known about this builtin. However: One example usage is: {1 2 3 4 5 4}0{.>}LO results in {1 2 3 4 5} | ||
LoopIndices | LI | Same thing as Loop but returns the indices of the elements instead of their values. Example usage: {0 0 2 3 4 5 4}0{==}LI results in {0 1} | ||
Map | m[ | Block ls, Block f | Apply f to every element in ls and collect the result in a block | |
m[ | Str ls, Block f | Defined as \/ XX \/ m[ \[ | ||
MapDup | [m | Defined as (^^)+]m[ | ||
MapParse | [M | Defined as (ps)+]m[ | ||
MapPretty | M[ | Defined as m[ sh | ||
MapProduct | mp | Defined as m[pd | ||
MapPush | MP | Defined as m[p^ | ||
MapPushMany | ^m | Prepends ^p then maps. | ||
MapPushManyReverse | m^ | Prepends p^ then maps. | ||
MapString | ]m | Defined as {*Sh}m[ (append Sh) | ||
MapSum | ms | Defined as m[++ | ||
MapWords | mw | Defined as m[wd | ||
MapUnlines | mu | Defined as m[ln | ||
MapToPretty | M] | Defined as {sh}m[ | ||
MapToPrettyFromFormat | m] | Defined as {shff}m[ | ||
Matches | ~= | String a, String regex | 1 if regex matches, else 0 | |
MatchesAll | ~? | String a, String regex | Returns a block of all substrings that matched the regex. "123b23""[0-9]+"~? results in {"123" "23"} | |
MatchesList | =~ | String a, String regex | Returns a list of subexpression matches | |
MatchRegex | ~& | String a, String regex | Returns a list with three elements. Everything before the match, the match and everything after it. "ab123cde""[0-9]+"~& results in {"ab" "123" "cde"} | |
MatrixMultiplication | mm | Block a,Block b | Matrix multiplication | |
Max | >. | Any a, Any b | Max(a,b) | |
Maximum | >] | Block a | Maximum(a) | |
>] | Str a Int a | Biggest character | ||
MaximumBy | >m | Defined as Cmsb<--] | ||
Min | <. | Any a, Any b | Min(a,b) | |
Minimum | <] | Block a | Minimum(a) | |
<] | Str a Int a | Smalles character | ||
MinimumBy | <m | Defined as Cmsb-] | ||
Modulo | .% | Int a, Int b | a `mod` b | |
.% | deepzip (int) | |||
Move | MV | Int n | Moves the n-th element of the stack to the top | |
MkAnd | m& | BlsqBlock a, BlsqBlock b | Defined as ^^ae!\/be!&& (bold stuff refers to the arguments passed) | |
MkOr | m| | BlsqBlock a, BlsqBlock b | Defined as ^^ae!\/be!|| (bold stuff refers to the arguments passed) | |
MkXor | m$ | BlsqBlock a, BlsqBlock b | Defined as ^^ae!\/be!$$ (bold stuff refers to the arguments passed) | |
Mul | .* | Int a, Int b | Regular integer multiplication (a * b) | |
.* | Double a, Double b | Multiplication (a * b) | ||
.* | Str a, Int n | Returns a block containing n copies of a | ||
.* | Char a, Int n | Returns a string containing n copies of a | ||
.* | Block a, Int n | Returns a block containing n copies of a | ||
.* | Double a, Int b | (a * b) | ||
.* | Int a, Double b | (a * b) | ||
MultiplesOf | mo | Defined as 1R@\/?* (infinite block of multiples) | ||
.* | Str a,Str b | reverse b++a | ||
Negate | ng | Defined as -1?* | ||
Nub | NB | Block a Str a Int a | Remove duplicate elements | |
Null | nu | Defined as L[n! | ||
NormalDCumulative | nc | Double mean, Double std, Double c | normal distribution cumulative | |
NormalDDensity | nd | Double mean, Double std, Double c | normal distribution density | |
NormalDQuantile | nq | Double mean, Double std, Double c | normal distribution quantile | |
Not | n! | Int a | Boolish not | |
n! | Block a Str a | Most common element | ||
NotEqual | != | Defined as == n! | ||
NotZero? | nz | Defined as z?n! | ||
nCr | nr | Int n, Int k | nCr(n,k) | |
nr | deepzip (int) | |||
Or | || | Int a, Int b | Bitwise or | |
|| | deepzip2 (int) | |||
OrLs | r| | Defined as {||}r[ | ||
PadLeft | P[ | Str a, Int c, Char b Block a, Int c, Any b | Pad (left) a to length c with b | |
PadRight | [P | Str a, Int c, Char b Block a, Int c, Any b | Pad (right) a to length c with b | |
Parse | ps | Str a | Parses the string as a Burlesque expression and returns a Block | |
ps | deepmap | |||
ParseEval | pe | Defined as pse! | ||
ParseId | PI | Like Parse but only returns the Head of the Block | ||
Partial | pa | Block xs, Block f | Partial generates inits from xs and applies f to each of those. {1 2 3 4}{++}pa results in {1 3 6 10}. This builtin is horribly slow. | |
Partition | pt | Block xs, Block p Str xs, Block p | Partitions a block (or str) into two blocks containing elements which satisfy p and not satisfying p. (Like doing two filter passes with p and with NOT p). | |
PoissonDCumulative | pc | Double lambda, Double c | poisson distribution cumulative | |
PoissonDPropability | pp | Double lambda, Int nth | poisson distribution probability | |
Pop | vv | Remove top most element from the stack | ||
PopSwap | v/ | Defined as vv \/ | ||
Pow | ** | Int a, Int b | Regular integer power (a ^ b) | |
** | Double a, Double b | Double power (a ** b) | ||
** | Block a, Block b | Merge blocks | ||
** | Str a, Str b | Merge strings | ||
** | Char a | ordinal a. (ord a). | ||
PlusMinus | pm | Defined as .+.- | ||
PrefixOf | ~! | Block a, Block b | Is b a prefix of a? | |
~! | Int a, Int b | Is b a prefix of a? | ||
~! | Str a, Str b | Is b a prefix of a? | ||
Pretty | sh Q | Any a | Convert to pretty type (FormatNormal) | |
PrettyPretty | sH | Defined as SHsh | ||
PrettyFormatFromFormat | SH | n/a | Defined as \/ sh \/ Ff | |
PrettyFromFormat | Sh | n/a | Defined as sh ff | |
Prepend | +] | String a, Char b Block a,Any b Int a,Int b | Prepends b to a | |
PrimeFactors | fC | Int a | Prime factorization of a (8 = 2 * 2 * 2) | |
fC | Double a | a * a (multiplies a with a) | ||
fC | deepmap | |||
Product | pd | Block a | Defined as {.*}r[. Returns Int 1 on empty list. | |
pd | Double a | Ceiling a | ||
pd | Int a | Convert to double | ||
ProductMany | PD | Defined as {pd}m[ | ||
PushMany | ^p | Str a Block a | Push every element to the stack | |
PushManyReverse | p^ | n/a | Like ^p but in reverse order | |
RandomInts | rn | Int seed, Int low, Int high | Returns an infinite block of random (by seed) ints with range (low,high). | |
RandomDoubles | RN | Int seed, Double low, Double high | Returns an infinite block of random (by seed) doubles with range (low,high). | |
Range | r@ | Int a, Int b | A block containing natural numbers from a to b (range a b) | |
r@ | Char a, Char b | Same, except for characters | ||
r@ | Double a | Square root | ||
r@ | String a | All permutations of a | ||
r@ | Block a | All permutations of a | ||
RangeFromOne | ro | Defined as 1\/r@ | ||
RangeFromZero | rz | Defined as 0\/r@ | ||
RangeInf | R@ | Int a | A block containing natural numbers from a to Infinity | |
R@ | Str a Block a | All subsequences of a | ||
RangeInfFromZero | r0 | Defined as 0R@ | ||
RangeInfFromOne | r1 | Defined as 1R@ | ||
RangeConcat | r\ | Defined as r@\[ | ||
RangeModulo | rm | Int x, Block [Int lo, Int hi] | Bound x into range (lo,hi) using modulo (((x - lo) `mod` (succ (hi-lo))) + lo) | |
ReadInt | ri | Int a | Identity for integers | |
ri | Str a | Tries to convert a string to an integer | ||
ri | Char a | Is Alpha numeric? | ||
ri | deepmap | |||
ReadDouble | rd | Double a | Identity for doubles | |
rd | Str a | Tries to convert a string to an double | ||
rd | Char a | Is Alpha? | ||
rd | deepmap | |||
ReadArray | ra | Str a | Tries to read an array in [,] notation | |
ra | Char | Is space? | ||
ra | deepmap | |||
Reduce | r[ | Block ls, Block f | Reduce ls with f | |
RemoveAt | RA | Block ls, Int idx Str ls, Int idx | Remove element at index idx from ls | |
RA | Block ls Str ls | Defined as sapd2.0./av!! | ||
Reverse | <- | Int a | Reverses the digits of the integer | |
<- | Str a | Reverses the string | ||
<- | Block a | Reverses the block | ||
<- | Char a | Invert case | ||
ReverseStack | #< | Reverses the stack | ||
Replace | r~ | Block ls, Any old, Any new | Replaces old in ls with new | |
r~ | Str ls, Char old, Char new | Replaces old in ls with new | ||
r~ | Str ls, Str old, Str new | Replaces old in ls with new | ||
r~ | Int ls, Int old, Int new | Replaces old in ls with new (digitwise) | ||
ReplaceRegex | R~ | Str s, Str repl, Str regex | Regex replace | |
RightPad | rp | Defined as x/Shx/\/x/x/\/[P | ||
Round | r_ | Double a, Int b | Round a to b decimal places | |
r_ | Block a, Int b | Defined as {b r_}m[ | ||
Round2 | R_ | Defined as 0r_pd | ||
Rotate | rt | Defined as l_\/+] | ||
Rotate2 | RT | Defined as g_[+ | ||
Rotations | iR | Str xs Block xs | Generates all rotations. {1 2 3}iR results in {{1 2 3} {2 3 1} {3 1 2}} | |
Same | sm | Defined as ^^-]{*==}al. (Checks whether all elements in a list are equal to the head i.e. are the same) | ||
SelectIndices | si | Block ls, Block adr Str ls, Block adr | Select elements from ls by indices in adr. "ABCD"{1 0 3}si => "BAD" | |
SelectLines | sl | Defined as \/ln\siun | ||
SelectWords | sw | Defined as \/WD\/siwd | ||
SelectIf | SI | Defined as zi:^p)-]si | ||
SetAt | sa | Str ls, Char e, Int idx Block ls, Any e, Int idx | Set element in ls at index idx to e | |
sa | Block ls Str ls | Defined as ^^L[ | ||
Signum | sn | Int a Double a | Signum a | |
SimpleFormat | f~ | Defined as \/"~";;\/{Sh}m[**\[ | ||
Smaller | .< | Any a, Any b | Comparision (a < b) | |
Sort | >< | Str a Block a Int a | Sort a | |
>< | Char a | Is digit? | ||
SortEqual | =s | Defined as ><\/><== | ||
Sorted | so | Defined as ^^><== | ||
SortedNub | Sn | Defined as {><}m[NB | ||
SortedReverseNub | sN | Defined as {<>}m[NB | ||
SortedReverse | SO | Defined as ^^<>== | ||
SortReverse | <> | Defined as ><<- | ||
SortBy | sb | Block ls, Block f Str ls, Block f | SortBy f (f must return 0 (equal), 1 (greater) or -1 (smaller)) | |
SortByComparing | sc | Defined as CMsb | ||
SortGroup | sg | Defined as ><=[ | ||
Sin | Ts | Double a Int a | sinus | |
Ts | deepmap | |||
SpecialInput | SP | Str a | Can be used to read 2D-Input. Defined as ln{}[M | |
SpecialInputPretty | sp | Defined as SPsh | ||
SP | Block a | Can be used to write 2D-Output. Defined as {{Sh}m[wd}m[un | ||
Split | ;; | String str, String b | Split string by b | |
;; | Block ls, Block b | Split ls by b | ||
;; | Int ls, Int b | Split ls by b | ||
SplitRegex | sr | Str regex, Str s | Split s by regex | |
SplitRegex2 | ~; | Str a, Str regex | Like MatchesRegex2, but the resulting list does not contain the actual match. | |
StandardDeviation | SD | Obviously defined as vr?s | ||
StudentTDCumulative | Sc | Double param, Double c | StudentT distribution cumulative | |
StudentTDDensity | Sd | Double param, Double c | StudentT distribution density | |
StudentTDQuantile | Sq | Double param, Double c | StudentT distribution quantile | |
StrEqIgnoreCase | s= | Defined as zz\/zz\/== | ||
StringAdd | |+ | Defined as PIjPIj?+ | ||
StringDiv | |/ | Defined as PIjPIj?/ | ||
StringMul | |* | Defined as PIjPIj?* | ||
StringSub | |- | Defined as PIjPIj?- | ||
StringInc | |i | Defined as PI?i | ||
StringDec | |d | Defined as PI?d | ||
StringUnlines | Su | Defined as m]ln | ||
StringWords | Sw | Defined as m]wd | ||
StripLeft | S[ | Block a, Any b Str a, Char b | Strip (left) b from a | |
S[ | Int a | a * a (multiplies a with a) | ||
StripRight | [S | Block a, Any b Str a, Char b | Strip (right) b from a | |
StrStr | ss | Defined as ^^L[x/\/CO\/Fi . Returns the index of a substring in a string. like C's strstr | ||
Sub | .- | Int a, Int b | Regular integer subtraction (a - b) | |
.- | Double a, Double b | Subtraction (a - b) | ||
.- | Str a, Str b | String de-concatenation. If a "endsWith" b, remove b from a. | ||
.- | Block a, Block b | Block de-concatenation. If a "endsWith" b, remove b from a. | ||
.- | Int b, Str a Block a, Int b Str a,Int b Block a,Int b | Drop b characters from a | ||
.- | Double a, Int b | (a - b) | ||
.- | Int a, Double b | (a - b) | ||
Substrings | su | Str s Int s Block s | all substrings of s sorted by length | |
SuffixOf | !~ | Block a, Block b | Is b a suffix of a? | |
!~ | Int a, Int b | Is b a suffix of a? | ||
!~ | Str a, Str b | Is b a suffix of a? | ||
Sum | ++ | Block a | Defined as {.+}r[. Returns Int 0 on empty list | |
++ | Int a,Int b | Concatenate digits. | ||
Swap | \/ j | Swap elements on top of the stack. | ||
SwapDup | /^ | Defined as \/ ^^ | ||
SwapPop | /v | Defined as \/ vv | ||
Tail | [- | Block a Int a | All except first element. | |
[- | Str a | All except first character | ||
[- | Char a | Convert to string | ||
[- | Int a | All except first digit | ||
Tails | iS | Str xs Block xs | Generates all tails. {1 2 3}iS results in {{1 2 3} {2 3} {3} {}} | |
TakeWhile | tw | Block p Block ls | take elements from ls as long as p holds true | |
tw | Block p Str s | Defined as **tw\[ | ||
TakeWhileSwapped | TW | Defined as \/tw | ||
Tan | Tt | Double a Int a | tangens | |
Tt | deepmap | |||
ToDouble | td | Str s Int s Double s | Convert to double | |
ToInt | ti | Str s Int s Double s | Convert to int | |
ToLower | zz | Str a Char a | to lower case | |
zz | deepmap | |||
ToUpper | ZZ | Str a Char a | to upper case | |
ZZ | deepmap | |||
That | th | Removes everything from the stack except the element on the bottom | ||
Transpose | tp | Block a | Transpose block of blocks (Matrix transpose) | |
TrimLeft | t[ | Str a | Trim left | |
t[ | deepmap | |||
TrimRight | t] | Str a | Trim right | |
t] | deepmap | |||
TrimLeftRight | tt | Str a | Defined as t[ t] | |
TrimLines | tl | Defined as ln{tt}m[un | ||
TypeOf | to | Any a | Returns the type of a as Str | |
Undigits | ug | List digits, Int base | Reverses what Digits (dg) does. | |
Ungroup | U[ | Ungroups. (Reverses what f: does, except for the order, because f: sorts). Defined as {p^.*}\m | ||
Union | UN | Block a, Block b Str a,Str b Int a, Int b | Union | |
UniformDCumulative | uc | Double low, Double high, Double c | uniform distribution cumulative | |
UniformDDensity | ud | Double low, Double high, Double c | uniform distribution density | |
UniformDQuantile | uq | Double low, Double high, Double c | uniform distribution quantile | |
Unique | U_ | Defined as ^^NB== | ||
Unlines | un | n/a | Defined as "\n" \/ [[ \[ | |
UnlinesPretty | uN | Defined as unsh | ||
Unzip | u[ | Unzips. (Reverses what z[ does). Defined as ^^{-]}m[\/{[~}m[ | ||
Variance | vr | Defined as ^^^^avbx(?-)[+m[2?^++\/L[-.?/ | ||
Version | ?? | Version string | ||
Words | wd | Str a | Defined as " ";; | |
wd | Block a | Defined as ' \/[[\[ | ||
wd | a | Defined as \/]] | ||
Words2 | WD | Str a | Splits a string into a list of words. (This also treats other whitespaces which the regular wd does not). | |
Words3 | wD | Defined as wdsh | ||
While | w! | Block f, Block p | While p execute f. (p is expected to leave an Int on top of the stack)
Executing p does not affect the global stack. | |
w! | Block f | Same effect as {f}{}w! | ||
WithLines | wl | n/a | Defined as \/ ln \/ m[ un | |
WithLinesString | Wl | Defined as {*Sh}WL (appends Sh) | ||
WithLinesPretty | WL | n/a | Defined as wl sh | |
WithLinesParsePretty | wL | n/a | Defined as {ps*}WL (prepends ps to block) | |
WithWords | ww | n/a | Defined as \/ WD \/ m[ wd | |
WithWordsPretty | WW | n/a | Defined as wwsh | |
Xor | $$ | Int a, Int b | Bitwise xor | |
$$ | deepzip2 (int) | |||
Xplode | XX | Str a | Convert a to a block of characters | |
XX | Int a | Convert a to a block of digits | ||
XX | Double a | Convert a to block containing ceiling a and floor a | ||
XX | Char a | Convert a to a string | ||
XX | Block a | Identity | ||
XSwap | x/ | If the stack order is [a,b,c] XSwap changes it to [b,c,a] | ||
Zero? | z? | Returns 1 if the argument passed was zero, an empty string, an empty list or a null byte. | ||
Zip | z[ | Block a, Block b Str a,Str b Block a, Str b Str a,Block b | Zips | |
ZipIndices | zi | Defined as 0R@\/z[ | ||
ZipWith | Z[ | Defined as z[\/m[ | ||
ZipWithPush | Z] | Defined as {^p*}Z[. Prepends ^p. |
Syntax
Special :: oneOf ",)@:%" Double :: { digit }+ , "." , { digit }+ Int :: { digit }+ Char :: "'" , anyChar String :: "\"" , { anyChar }* , "\"" Block :: "{" , { Expression }* , "}" Quoted :: "(", ExpressionSingle , ")" Identifier :: noneOf "1234567890{},' \"" , anyChar SingleIdent :: oneOf "jJQ" ExpressionSingle :: { SingleIdent | Block | Int | Char | String | Quoted | Identifier } Expression = { ExpressionSingle }*
Format / Pretty
If you write a Burlesque program like "Hello, world!" you will see, that the output is also "Hello, world!" and not Hello, world!. Stuff is printed the same way you enter it in code unless you change it to the 'Pretty' type. The sh command for example does this. "Hello, world!"sh outputs Hello, world!. Keep in mind that sh changes the type to Pretty, so it's not a string anymore and you can not treat it as a string. A pretty value can have different formattings and currently the following exist:
- 0 - normal format
- 1 - no spaces
- 2 - with spaces
- 3 - raw format (as it would be printed if it were not prettied)
Lazy
Burlesque is a lazy programming language which means that it only evaluates stuff that is necessary to evaluate. A good example for this is the RangeInf command. 1R@"ABCD"z[ generates an infinite list 1..Infinity and zips it with "ABCD". However, its support for lazyness is limited and does not extend to every command.
Hack mode
Hack mode was an experimental feature that never made it into production.
Store load shortcuts
These are: a -> 0, b -> 1, c -> 2. For Load: #*. For Load2: !*. For Store: `*. Replace * with the corresponding letter. Example: 5 6hd#a.+`a33#a.+.Hides 6, loads it, adds it to 5, stores the result, push 33, load 0, add => 44.
Coerce commands
Coerce commands fall back to their none coerce corresponding commands if the arguments do not match!
Commands taking Int
Int is unbounded. However, some commands only work with bounded integers. Unbounded integers are automatically converted. This conversion from unbouded -> bounded can have side-effects.
Math constants
Pi : pi => 3.141592653589793e : ee => 2.718281828459045
Special
For , read the FAQ. ) is the block map modifier. It encloses the next token inside a map statement. Therefore
blsq ) {"abc" "dba"})<- {"cba" "abd"}: is the block filter modifier.
blsq ) "abc98a8"{><}f[ "988" blsq ) "abc98a8":>< "988"@ has multiple functions. When prefixed to an ident, it converts the ident into two characters.
blsq ) @az 'z 'aWhen @ is prefixed to a character it converts the character to an infinite string containing only said character.
blsq ) @'z100.+ "zzzzzzzzzzzzzzzzzzzzzzzzzz ...... zzzzzzzzzzzzzzzzzzzzz"When @ is prefixed to an integer it is converted to a double.
blsq ) @5 5.0
Advanced manipulation functions
- #Q -- Push remaining code to stack
- #q -- Pop code from stack and replace remaining code with it
- #j -- Pop code from stack and prepend it to remaining code
- #J -- Pop code from stack and append it to remaining code
- #s -- Push stack to stack
- #S -- Pop stack from stack
- #r -- Rotate stack left
- #R -- Rotate stack right
Global state stack
Since Burlesque 1.7.3 you can use state even inside maps/filters etc. (However, this doesn't work for sortBy yet). Burlesque 1.7.3 now runs with two stacks.
Global state stack commands
- PP - Pop an element from the state stack (and push it to the the normal stack)
- Pp - Push an element to the state stack (and pop it from the normal stack)
- pP - Peek an element from the state stack (and push it to the normal stack)
- p/ - Perform a swap on the state stack
- p\ - Swap the normal stack with the state stack
- P_ - Pop an element from the state stack
blsq ) 5Pp4Pp{1 1 1 1 1}{pPp/}m[ {4 1 5 1 4 1 5 1 4 1}