is a dynamically typed functional pure-ish language based on untyped lambda calculus etc etc. boring. it is also a minimalistic1 vector2 tacit3 programming language with postfix4, whitespace-based5 terse6 syntax
- there are not a lot of built-in functions (see primitives)
- boil values can either be scalars or vectors (which i will from here on just call "lists"). arithmetic operations like
+
(addition) map to every element in a list. - functions can be defined using combinators like
:
compose, as well as currying for partial evaluation. x-
means "minus x". application goes in left-to-right order- spaces are used to regroup things:
ABCD
is((AB)C)D
,A B CD
isA(B(CD))
.x yF
calls F with y and x - most built-in are just ascii symbols (these are called "primitives")
INTROduction (<- that blue thing is a link) (click there)
it's a sort of tutorial but not really and it's not that long look at it
- implementing stuff with lists
- arithmetic
- mapping
'
,|
- control flow (conditions, iteration, recursion)
- combinators
- perplexed face
:/
- reimplementing scan
- syntax (more details about how precedence works)
- commentary (inspirations, discourse, blah blah blah)
install factor (0.99 works) and then, replacing factor
by whichever name you have factor installed with,
factor boil.factor
,- or place boil in your work folder and
"boil" deploy
, - or if you dont know what that means,
git clone https://github.com/selaere/boil factor -e='USE: namespaces "." deploy-directory set "." add-vocab-root "boil" deploy' # ^ run outside the cloned repo
usage | name | example |
---|---|---|
x! |
iota | 5! .. { 0 1 2 3 4 } 5-! .. { -1 -2 -3 -4 -5 } "string" 4! .. "stri" 2 3; ! .. { { 0 1 } { 2 3 } { 4 5 } } |
x# |
length | 12 34 56 , # .. 3 "string"# .. 6 4# .. -1 |
x$ |
wrap | 3 4 5 ,$ .. { { 3 4 5 } } |
x% |
reciprocal | 3% .. 1/3 6 3%* .. 2 |
x y& |
match | "meow" "meow"& .. 1 "woof" "meow"& .. 0 |
x f' |
each | 3 1 2 ,!' .. { { 0 1 2 } { 0 } { 0 1 } } |
x y* |
times | 1 2 3 , 4 5 6 ,* .. { 4 10 18 } |
x y+ |
add | 1 2 3 , 4 5 6 ,+ .. { 5 7 9 } |
x- |
negate | 0 1 2 ,- .. { 0 -1 -2 } |
x f/ |
fold | 2 3 4 ,+/ .. 9 2 3 4 ,*/ .. 24 1 2 , 3 4 , 5 6 , , ;/ .. { 1 2 3 4 5 6 } |
x f g: |
compose | "cats" # !: .. { 0 1 2 3 } 1 2 3 ,1(- +:) .. { 0 1 2 } |
x y; |
concat | 1 2 3 , 4 5 6 ,; .. { 1 2 3 4 5 6 } 1 2 3 ,$ 4 5 6 ,$ ; .. { { 1 2 3 } { 4 5 6 } } 1 2; .. { 1 2 } 1 2 3 4 ,; .. { 1 2 3 4 } 1 2 3 , 4; .. { 1 2 3 4 } |
x y< |
less | 4 5 6 , 5< .. { 1 0 0 } |
x y= |
equal | 4 5 6 , 5= .. { 0 1 0 } |
x y> |
greater | 4 5 6 , 5> .. { 0 0 1 } |
x? |
where | 0 0 0 1 0 0 1 0 1 1 0 , ? .. { 3 6 8 9 } 0 1 3 0 2 0 4 , ? .. { 1 2 2 2 4 4 6 6 6 6 } |
x y@ |
const | 1 2@ .. 2 |
f x[ |
thrush | 3 "hello"[ .. 'l' + 2[ 3[ .. 5 |
x f\ |
scan | 4 2 5 3 2- 3 , +\ .. { 4 6 11 14 12 15 } |
x] |
id | 1] .. 1 2 -] .. -2 |
x f^ |
self | 4 *^ .. 16 |
x_ |
floor | 4.5_ .. 4 |
x y f` |
swap | 1 2 3 , 4 ;` .. { 4 1 2 3 } |
x y{ |
min | 4 5 6 , 5{ .. { 4 5 5 } |
x y f| |
zip | 1 2 3 , 4 5 6 , ;| .. { { 1 4 } { 2 5 } { 3 6 } } |
x y} |
max | 4 5 6 , 5} .. { 5 5 6 } |
x~ |
grade |
3 5 1 4 3 2 3 0 ,~ .. { 7 2 5 0 4 6 3 1 } 3 5 1 4 3 2 3 0 ,~^ .. { 0 1 2 3 3 3 4 5 } |
xSin
xCos
xTan
xAsin
xAcos
xAtan
xSqrt
xRound
xExp
xLn
do exactly what you expect them to do (see arithmetic)b nPow
is b to the power of nxDeco
returns the two components of ratio xpi
is pi
these are the reason why i said "pure-ish" at the start:
input
gets all the input from stdin until eofsWrite
writes a string to stdoutsPrint
writes a string to stdout with a trailing newlinexOut
prettyprints x and returns xxOuts
prettyprints x and returns x, where lists with only numbers will be formatted as stringsnRand
returns a random integer in [0, n). if n = 0, return a random float in [0.0, 1.0)
if you call the executable with no arguments you get sent to a repl. type in expressions, press enter, and pretty-printed results come out! if you write a line with var.
at the end, the result of that expression will be saved in the repl environment with the name var. you can also access the last result with z
. there are also some other commands that can be used at the beginning of a line (these will probably change):
)q
: quit)s
: pretty-prints the result, where lists with only numbers will be formatted as strings)v
: show name of every variable set in the environment)p
: parse the expression and print out the AST without running it