← main page basics · series · spreadsheets ·

Function reference: builtins

work in progress

Printing functions

Functions that print values to stdout.

print

Builtin(1): Prints a value and adds a newline.

print 123
; prints "123
; "

prn

Builtin(1): Prints a value without newline.

prn 123
; prints "123"

prns

Builtin(1): Prints a value and adds a space.

prns 123
; prints "123 "

print\val

Builtin(2): Prints a value and adds a newline.

print\val 33 "value is: {{}}"
; prints "value is: 33
; "

probe

Builtin(1): Prints a probe of a value.

probe 33
; prints "[Integer: 33]
; "

Working with numbers

Functions that mostly work with numbers.

inc

Pure Builtin(1): Returns integer value incremented by 1.

inc 100
; returns 101

is-positive

Pure Builtin(1): Returns true if integer is positive.

is-positive 1
; returns 1
0 .is-positive
; returns 0

is-zero

Pure Builtin(1): Returns true if integer is zero.

is-zero 0
; returns 1
0 .is-zero
; returns 1
is-zero 0.000000
; returns 1
is-zero 0.100000
; returns 0

factor-of

Pure Builtin(2): Checks if a first argument is a factor of second.

factor-of 10 2
; returns 1
10 .factor-of 3
; returns 0

odd

Pure Builtin(1): Checks if a number is odd.

odd 3
; returns 1

even

Pure Builtin(1): Checks if a number is even.

even 2
; returns 1

mod

Pure Builtin(2): Calculates module (remainder) of two integers.

3 .mod 2
; returns 1

Logic functions

Function that help with logical operations.

true

Pure Builtin(0): Returns a truthy value.

true
; returns 1

false

Pure Builtin(0): Returns a falsy value.

false
; returns 0

not

Pure Builtin(1): Turns a truthy value to a non-truthy and reverse.

not 0
; returns 1
not 1
; returns 0

and

Pure Builtin(2): Bitwise AND operation between two values.

1 .and 0
; returns 0
1 .and 1
; returns 1
0 .and 0
; returns 0

or

Pure Builtin(2): Bitwise OR operation between two values.

1 .or 0
; returns 1
1 .or 1
; returns 1
0 .or 0
; returns 0

xor

Pure Builtin(2): Bitwise XOR operation between two values.

0 .xor 0
; returns 0
1 .xor 1
; returns 0
0 .xor 1
; returns 1
1 .xor 0
; returns 1

all

Builtin(1): Takes a block, if all values or expressions are truthy it returns the last one, otherwise false.

all { 1 1 1 }
; returns 1
{ 0 0 1 } .all
; returns 0

any

Builtin(1): Takes a block, if any of the values or expressions are truthy, the it returns that one, in none false.

any { 0 0 1 }
; returns 1
{ 0 0 0 } .any
; returns 0

Working with strings

Functions that mostly work with strings.

capitalize

Pure Builtin(1): Takes a String and returns the same String, but with first character turned to upper case.

capitalize "anne"
; returns "Anne"

to-lower

Pure Builtin(1): Takes a String and returns the same String, but with all characters turned to lower case.

to-lower "ANNE"
; returns "anne"

to-upper

Pure Builtin(1): Takes a String and returns the same String, but with all characters turned to upper case.

to-upper "anne"
; returns "ANNE"

join

Pure Builtin(1): Joins Block or list of values together.

join { "Marry" "Anne" }
; returns "MarryAnne"

join\with

Pure Builtin(2): Joins Block or list of values together.

join\with { "Marry" "Anne" } ","
; returns "Marry,Anne"

split

Pure Builtin(2): Splits a string into a block of values using a separator

split "Marry,Anne" ","
; returns { "Marry" "Anne" }

split\quoted

Pure Builtin(3): Splits a line of string into values by separator by respecting quotes

split\quoted ""Marry,Anne",Joe" "," """
; returns { "Marry,Anne" "Joe" }

split\every

Pure Builtin(2): Splits a string into a block of values using a separator

split\every "abcbce" 3
; returns { "abc" "bce" }

Many of functions that work with other collections also work with strings.

Working with blocks and lists

Functions that mostly work with collections (blocks / lists).

range

Builtin(2): Takes two integers and returns a block of integers between them. (Will change to lazy list/generator later)

range 1 5
; returns { 1 2 3 4 5 }

first

Builtin(1): Accepts a Block, List or String and returns the first item.

first { 1 2 3 4 5 }
; returns 1
first list { 1 2 3 4 5 }
; returns 1
first "12345"
; returns "1"
try { first { } } |type?
; returns error
try { first list { } } |type?
; returns error
try { first "" } |type?
; returns error

rest

Builtin(1): Accepts a Block, List or String and returns all but first item.

rest { 1 2 3 4 5 }
; returns { 2 3 4 5 }
rest list { 1 2 3 4 5 }
; returns L[ 2  3  4  5 ]
rest "12345"
; returns "2345"
try { rest { } } |type?
; returns error
try { rest list { } } |type?
; returns error
try { rest "" } |type?
; returns error

rest\from

Builtin(2): Accepts a Block, List or String and an Integer N, returns all but first N items.

rest\from { 1 2 3 4 5 } 2
; returns { 3 4 5 }
rest\from list { 1 2 3 4 5 } 2
; returns L[ 3  4  5 ]
rest\from "12345" 2
; returns "345"
try { rest\from { } } |type?
; returns error
try { rest\from list { } } |type?
; returns error
try { rest\from "" } |type?
; returns error

second

Builtin(1): Accepts a Block, List or String and returns the second value in it.

second { 1 2 3 4 5 }
; returns 2
second list { 1 2 3 4 5 }
; returns 2
second "12345"
; returns "2"
try { second { } } |type?
; returns error
try { second list { } } |type?
; returns error
try { second "" } |type?
; returns error

third

Builtin(1): Accepts a Block, List or String and returns the third value in it.

third { 1 2 3 4 5 }
; returns 3
third list { 1 2 3 4 5 }
; returns 3
third "12345"
; returns "3"
try { third { } } |type?
; returns error
try { third list { } } |type?
; returns error
try { third "" } |type?
; returns error

nth

Builtin(2): Accepts a Block, List or String and Integer N, returns the N-th value.

nth { 1 2 3 4 5 } 4
; returns 4
nth list { 1 2 3 4 5 } 4
; returns 4
nth "12345" 4
; returns "4"
try { nth { } } |type?
; returns error
try { nth list { } } |type?
; returns error
try { nth "" } |type?
; returns error

->

Builtin(2):

{ 11 22 33 } |_-> 1
; returns 22
list { 11 22 33 } |_-> 1
; returns 22
dict { "a" 11 "b" 22 "c" 33 } |_-> "b"
; returns 22

<-

Builtin(2):

2 <- { 11 22 33 }
; returns 33
2 <- list { 11 22 33 }
; returns 33
"c" <- dict { "a" 11 "b" 22 "c" 33 }
; returns 33

last

Builtin(1): Accepts a Block, List or String and returns the last value in it.

last { 1 2 3 4 5 }
; returns 5
last list { 1 2 3 4 5 }
; returns 5
last "12345"
; returns "5"
try { last { } } |type?
; returns error
try { last list { } } |type?
; returns error
try { last "" } |type?
; returns error

head

Builtin(2): Accepts a Block, List or String and an Integer N, returns the first N values.

head { 1 2 3 4 5 } 2
; returns { 1 2 }
head { 1 2 3 4 5 } 10
; returns { 1 2 3 4 5 }
head { } 2
; returns { }
head list { 1 2 3 4 5 } 2
; returns L[ 1  2 ]
head list { 1 2 3 4 5 } 10
; returns L[ 1  2  3  4  5 ]
head list { } 2
; returns L[]
head "12345" 2
; returns "12"
head "12345" 10
; returns "12345"
head "" 2
; returns ""

tail

Builtin(2): Accepts a Block, List or String and Integer N, returns the last N items.

tail { 1 2 3 4 5 } 2
; returns { 4 5 }
tail { 1 2 3 4 5 } 10
; returns { 1 2 3 4 5 }
tail { } 2
; returns { }
tail list { 1 2 3 4 5 } 2
; returns L[ 4  5 ]
tail list { 1 2 3 4 5 } 10
; returns L[ 1  2  3  4  5 ]
tail list { } 2
; returns L[]
tail "12345" 2
; returns "45"
tail "12345" 10
; returns "12345"
tail "" 2
; returns ""

length?

Builtin(1): Accepts a collection (String, Block, Dict, Spreadsheet) and returns it's length.

length? "1234567"
; returns 7
{ 1 2 3 4 5 } .length?
; returns 5
list { 1 2 3 } |length?
; returns 3

list

Builtin(1): Constructs a List from the Block of values.

list { "a" 1 "b" 2 } |type?
; returns list

dict

Builtin(1): Constructs a Dict from the Block of key and value pairs.

dict { "a" 1 "b" 2 } |type?
; returns dict

min

Builtin(1): Constructs a Dict from the Block of key and value pairs.

min { 8 2 10 6 }
; returns 2
min list { 8 2 10 6 }
; returns 2
try { min { } } |type?
; returns error
try { min list { } } |type?
; returns error

max

Builtin(1): Constructs a Dict from the Block of key and value pairs.

max { 8 2 10 6 }
; returns 10
max list { 8 2 10 6 }
; returns 10
try { max { } } |type?
; returns error
try { max list { } } |type?
; returns error

avg

Builtin(1): Constructs a Dict from the Block of key and value pairs.

avg { 8 2 10 6 }
; returns 6.500000
avg list { 8 2 10 6 }
; returns 6.500000
try { avg { } } |type?
; returns error
try { avg list { } } |type?
; returns error

sum

Builtin(1): Accepts a Block or List of values and returns the sum.

sum { 8 2 10 6 }
; returns 26
sum { 8 2 10 6.500000 }
; returns 26.500000
sum { }
; returns 0
sum list { 8 2 10 6 }
; returns 26
sum list { 8 2 10 6.500000 }
; returns 26.500000
sum list { }
; returns 0

union

Builtin(2): Accepts a block or list of values and returns only unique values.

union { 8 2 } { 1 9 } |length?
; returns 4
union { } { 1 9 } |length?
; returns 2
union { } { }
; returns { }

intersection

Pure Builtin(2): Finds the intersection of two values.

intersection { 1 3 5 6 } { 2 3 4 5 }
; returns { 3 5 }
intersection { } { 2 3 4 }
; returns { }
intersection { } { }
; returns { }

unique

Builtin(2): Accepts Rye value and Tagword with a Block or String. Appends Rye value to Block/String in place, also returns it .

{ 3 2 3 5 3 2 } .list .unique .length?
; returns 3

Type conversion and checking

Functions that convert between Rye value types.

to-word

Pure Builtin(1): Tries to change a Rye value to a word with same name.

to-word "test"
; returns test
to-word 'test
; returns test

to-integer

Builtin(1): Tries to change a Rye value (like string) to integer.

to-integer "123"
; returns 123

to-string

Pure Builtin(1): Tries to turn a Rye value to string.

to-string 123
; returns "123"
to-string 'word
; returns "word"

to-uri

Pure Builtin(1): Tries to change Rye value to an URI.

to-uri "https://example.com"
; returns https://example.com

to-file

Pure Builtin(1): Tries to change Rye value to a file.

to-file "file.txt"
; returns file://file.txt

to-context

Builtin(1): Takes a Dict and returns a Context with same names and values.

cc: to-context dict { "name" "Jim" } , cc
; returns "Jim"

is-integer

Pure Builtin(1): Returns true if value is an integer.

is-integer 123
; returns 1
is-integer "ABC"
; returns 0

is-decimal

Pure Builtin(1): Returns true if value is a decimal.

is-decimal 123.456000
; returns 1
is-decimal 123
; returns 0
is-decimal "ABC"
; returns 0

is-number

Pure Builtin(1): Returns true if value is a number (integer or decimal).

is-number 123
; returns 1
is-number 123.456000
; returns 1
is-number "ABC"
; returns 0

is-string

Pure Builtin(1): Returns true if value is a string.

is-string "ABC"
; returns 1
is-string 123
; returns 0
is-string file://file.txt
; returns 0
is-string test@gmail.com
; returns 0

type?

Pure Builtin(1): Returns the type of Rye value as a word.

type? "ABC"
; returns string
type? 123
; returns integer

Serializers and loaders

Functions that print values to stdio

mold

Builtin(1): Turn value to it's string representation.

mold 33
; returns "33"

mold\unwrap

Builtin(1): Turn value to it's string representation.

mold\nowrap "33"
; returns ""33""

capture-stdout

Builtin(1): Takes a block of code and does (runs) it.

capture-stdout { "out" .print , "not this" }
; returns "out
; "

dump

Pure Builtin(1): Retunrs (dumps) content of a function.

fn { x } { x + 1 } |dump
; returns { fn { x } { x ._+ 1 } }

doc\of?

Pure Builtin(1): Get docstring of the passed context.

fn { x "docstring" } { x + 1 } |doc\of?
; returns "docstring"

load

Builtin(1): Loads a string into Rye values.

load "1 2 3" |type?
; returns block
load "1 2 3" |length?
; returns 3
load "1 2 { print 4 }" |third |length?
; returns 2
load "1 2 { print 4 }" |third |first |type?
; returns word

Conditional functions

Program flow control functions

if

Pure Builtin(2): Basic conditional. Takes a condition and a block of code.

if 1 { 101 }
; returns 101
if 0 { 101 }
; returns 0

otherwise

Pure Builtin(2): Conditional if not. Takes condition and a block of code.

otherwise 1 { 101 }
; returns 0
otherwise 0 { 101 }
; returns 101

^if

Pure Builtin(2): Basic conditional with a Returning mechanism when true. Takes a condition and a block of code.

^if 0 { 101 }
; returns 0

^otherwise

Pure Builtin(2): Basic conditional with a Returning mechanism when true. Takes a condition and a block of code.

^otherwise 1 { 101 }
; returns 0

either

Pure Builtin(3): The if/else conditional. Takes a value and true and false block of code.

either 1 { 101 } { 202 }
; returns 101
either 0 { 101 } { 202 }
; returns 202

switch

Builtin(2): Classic switch function. Takes a word and multiple possible values and block of code to do.

switch 1 { 1 { 101 } 2 { 202 } }
; returns 101
switch 2 { 1 { 101 } 2 { 202 } }
; returns 202

cases

Builtin(2): Similar to Case function, but checks all the cases, even after a match. It combines the outputs.

cases 1 { { 1 } { + 10 } { 1 } { + 100 } }
; returns 111
cases 1 { { 0 } { + 10 } { 1 } { + 100 } }
; returns 101

Looping functions

Program flow control functions

loop

Pure Builtin(2): Basic conditional. Takes a condition and a block of code.

loop 3 { prns "x" }
; prints "x x x "

for

Pure Builtin(2): Conditional if not. Takes condition and a block of code.

for { 1 2 3 } { prns "x" }
; prints "x x x "
{ "a" "b" "c" } .for { .prns }
; prints "a b c "

forever

Builtin(1): Accepts a block and does it forever.

forever { "once" .prn .return }
; prints "once"

forever\with

Builtin(2):

forever\with 1 { .prn .return }
; prints "1"

Doers and evaluators

Functions that do code and evaluate blocks.

do

Builtin(1): Takes a block of code and does (runs) it.

do { 101 + 101 }
; returns 202

do-in

Builtin(2): Takes a Context and a Block. It Does a block inside a given Context.

cc: context { x: 101 } do-in cc { x + 101 }
; returns 202

with

Builtin(2): Takes a value and a block of code. It does the code with the value injected.

1 .with { + 100 }
; returns 101

try

Builtin(1): Takes a block of code and does (runs) it.

try { 10 + unknown } |type?
; returns error

do-in\try

Builtin(2): Takes a Context and a Block. It Does a block inside a given Context.

ctx: context { x: 101 } do-in\try ctx { x / 0 } |type?
; returns error

vals

Builtin(1): Takes a block of Rye values and evaluates each value or expression.

x: 101 vals { x }
; returns { 101 }
name: "Anne" vals { name "Goodall" }
; returns { "Anne" "Goodall" }
y: 202 vals { 101 y y + 101 }
; returns { 101 202 303 }

vals\with

Builtin(2): Evaluate a block with injecting the first argument.

vals\with 100 { + 1 }
; returns { 101 }

time-it

Builtin(1): Accepts a block, does it and times it's execution time.

time-it { 1 + 1 }
; returns 0

Function creating functions!?

Functions that create functions.

does

Pure Builtin(1): Creates a function without arguments.

f: does { prns "Hey" } f f
; prints "Hey Hey "

fn

Pure Builtin(2): Creates a function.

f: fn { x } { prns x } f "A" f "B"
; prints "A B "

fn1

Pure Builtin(1): Creates a function that accepts one anonymouse argument.

f: fn1 { .prns } f "A" f "B"
; prints "A B "

pfn

Pure Builtin(2): Creates a pure function.

add10: pfn { x } { x + 10 } add10 9
; returns 19
x: 10 f: pfn { } { prns 1 } try { f } |type?
; returns error
x: 10 f: pfn { } { x } try { f } |type?
; returns error

Pure functions only have access to other pure functions.

closure

Pure Builtin(2): Creates a function with specific context.

x: 10 cl: fn { } { prns x } , context { x: 99 cl }
; prints "99 "
x: 10 cl: closure { } { prns x } , context { x: 99 cl }
; prints "10 "

Code flow combinators

Program flow control functions

pass

Builtin(2): Accepts a value and a block. It does the block, with value injected, and returns (passes on) the initial value.

"xxx" .pass { + "yyy" :xy }
; returns "xxx"

keep

Builtin(3): Do the first block, then the second one but return the result of the first one.

10 .keep { + 1 } { * 10 }
; returns 11

wrap

Builtin(2): TODODOC

Higher order like functions

Functions for usual HOF patterns, map, reduce, filter.

map

Pure Builtin(2): Maps values of a block to a new block by evaluating a block of code.

map { 1 2 3 } { + 1 }
; returns { 2 3 4 }
map { } { + 1 }
; returns { }
map { "aaa" "bb" "c" } { .length? }
; returns { 3 2 1 }
map list { "aaa" "bb" "c" } { .length? }
; returns L[ 3  2  1 ]
map list { 3 4 5 6 } { .factor-of 3 }
; returns L[ 1  0  0  1 ]
map list { } { + 1 }
; returns L[]
map "123" { .to-integer }
; returns { [NIL][NIL][NIL]1 2 3 }
map "123" to-integer
; returns { 1 2 3 }
map "" { + "-" }
; returns { }

map\pos

Pure Builtin(3): Maps values of a block to a new block by evaluating a block of code.

map\pos { 1 2 3 } 'i { + i }
; returns { 2 4 6 }
map\pos { } 'i { + i }
; returns { }
map\pos list { 1 2 3 } 'i { + i }
; returns L[ 2  4  6 ]
map\pos list { } 'i { + i }
; returns L[]
map\pos "abc" 'i { + i }
; returns { [NIL][NIL][NIL]"a1" "b2" "c3" }
map\pos "" 'i { + i }
; returns { }

filter

Pure Builtin(2): Filters values from a seris based on return of a injected code block.

filter { 1 2 3 4 } { .even }
; returns { 2 4 }
filter { 1 2 3 4 } even
; returns { 2 4 }
filter { } { .even }
; returns { }
filter list { 1 2 3 4 } { .even }
; returns L[ 2  4 ]
filter list { 1 2 3 4 } even
; returns L[ 2  4 ]
filter list { } { .even }
; returns L[]
filter "1234" { .to-integer .even }
; returns { "2" "4" }
filter "01234" to-integer
; returns { "1" "2" "3" "4" }
filter "" { .to-integer .even }
; returns { }

seek

Pure Builtin(2): Seek over a series until a Block of code returns True and return the value.

seek { 1 2 3 4 } { .even }
; returns 2
seek list { 1 2 3 4 } { .even }
; returns 2
seek "1234" { .to-integer .even }
; returns "2"
try { seek { 1 2 3 4 } { > 5 } } |type?
; returns error
try { seek list { 1 2 3 4 } { > 5 } } |type?
; returns error
try { seek "1234" { .to-integer > 5 } } |type?
; returns error

purge

Builtin(2): Purges values from a series based on return of a injected code block.

purge { 1 3 3 } { .even }
; returns { 1 3 }
purge { } { .even }
; returns { }
purge list { 1 2 3 } { .even }
; returns L[ 1  3 ]
purge list { } { .even }
; returns L[]
purge "1234" { .to-integer .even }
; returns { "1" "3" }
purge "" { .to-integer .even }
; returns { }

reduce

Pure Builtin(3): Reduces values of a block to a new block by evaluating a block of code ...

reduce { 1 2 3 } 'acc { + acc }
; returns 6
reduce list { 1 2 3 } 'acc { + acc }
; returns 6
reduce "abc" 'acc { + acc }
; returns "cba"
try { reduce { } 'acc { + acc } } |type?
; returns error
try { reduce list { } 'acc { + acc } } |type?
; returns error
try { reduce "" 'acc { + acc } } |type?
; returns error

fold

Pure Builtin(4): Reduces values of a block to a new block by evaluating a block of code ...

fold { 1 2 3 } 'acc 1 { + acc }
; returns 7
fold { } 'acc 1 { + acc }
; returns 1
fold list { 1 2 3 } 'acc 1 { + acc }
; returns 7
fold list { } 'acc 1 { + acc }
; returns 1
fold "abc" 'acc "123" { + acc }
; returns "cba123"
fold "" 'acc "123" { + acc }
; returns "123"

partition

Pure Builtin(2): Partitions a series by evaluating a block of code.

partition { 1 2 3 4 } { > 2 }
; returns { { 1 2 } { 3 4 } }
partition { "a" "b" 1 "c" "d" } { .is-integer }
; returns { { "a" "b" } { 1 } { "c" "d" } }
partition { "a" "b" 1 "c" "d" } is-integer
; returns { { "a" "b" } { 1 } { "c" "d" } }
partition { } { > 2 }
; returns { { } }
partition list { 1 2 3 4 } { > 2 }
; returns L[ L[ 1  2 ]  L[ 3  4 ] ]
partition list { "a" "b" 1 "c" "d" } is-integer
; returns L[ L[ a  b ]  L[ 1 ]  L[ c  d ] ]
partition list { } { > 2 }
; returns L[ L[] ]
partition "aaabbccc" { , }
; returns L[ aaa  bb  ccc ]
partition "" { , }
; returns L[  ]
partition "aaabbccc" is-string
; returns L[ aaabbccc ]

group

Function(4)

{ } .list .group { .first }
; returns [
; ]
try { { 1 2 3 4 } .group { .even } } |type?
; returns error

produce

Builtin(3): Accepts a number, initial value and a block of code. Does the block of code number times, injecting the number.

produce 5 0 { + 3 }
; returns 15

sum-up

Pure Builtin(2): Reduces values of a block or list by evaluating a block of code and summing the values.

sum-up { 1 2 3 } { * 10 }
; returns 60
sum-up { 1 2 3 } { * 2.500000 }
; returns 15.000000
sum-up { 1 2.500000 3.500000 } { * 10 }
; returns 70.000000
sum-up { "1" "2" "3" } to-integer
; returns 6
sum-up { } { * 10 }
; returns 0
sum-up list { 1 2 3 } { * 10 }
; returns 60
sum-up list { 1 2.500000 3.500000 } { * 10 }
; returns 70.000000
sum-up list { "1" "2" "3" } to-integer
; returns 6
sum-up list { } { * 10 }
; returns 0

Context related functions

Functions for handling and working with Context.

current-ctx

Builtin(0): Returns current context.

current-ctx |type?
; returns ctx

parent-ctx

Builtin(0): Returns parent context of the current context.

cc: context { f: does { parent-ctx |type? } } , cc
; returns ctx

context

Builtin(1): Creates a new context with no parent

context { x: does { 1 + 1 } } :cc , cc
; returns 2

isolate

Builtin(1):

isolate { x: does { 1 + 1 } } :cc , try { cc } |type?
; returns error

raw-context

Builtin(1):

cc: raw-context { name: "Jim" } |type?
; returns ctx

private

Builtin(1): Creates a new context with current parent, returns last value

private { x: 3 , x + 30 } :x
; returns 33

extend

Builtin(2): Extends a context with a new context in place and returns it.

c1: context { x: 1 } , c2: extend c1 { y: 2 } , c2
; returns 1

bind

Builtin(2):

isolate { x: does { 1 + 1 } } |bind current-ctx :cc , cc
; returns 2

unbind

Builtin(1): Accepts a Context and unbinds it from it's parent Context.

context { x: does { 1 + 1 } } |unbind :cc , try { cc } |type?
; returns error

Failure handling functions

Functions for handling and working with Context.

fail

Builtin(1): Constructs and Fails with an Error object. Accepts String as message, Integer as code, or block for multiple parameters.

fail 404 |disarm |code?
; returns 404
fail "message" |disarm |mold
; returns "Error: message "
fail { 501 "auth error" } |disarm |mold
; returns "Error(501): auth error "

failure

Builtin(1): Constructs and Error object. Accepts String as message, Integer as code, or block for multiple parameters.

failure 403 |type?
; returns error

code?

Builtin(1): Constructs and Fails with an Error object. Accepts String as message, Integer as code, or block for multiple parameters.

failure 403 |code?
; returns 403

disarm

Builtin(1): Constructs and Fails with an Error object. Accepts String as message, Integer as code, or block for multiple parameters.

failure 403 |disarm
; returns Error(403):  

failed?

Builtin(1): Constructs and Fails with an Error object. Accepts String as message, Integer as code, or block for multiple parameters.

fail 403 |failed?
; returns 1

check

Builtin(1): Constructs and Fails with an Error object. Accepts String as message, Integer as code, or block for multiple parameters.

1 / 0 |check 501 |code?
; returns 501

fix

Builtin(1): Constructs and Fails with an Error object. Accepts String as message, Integer as code, or block for multiple parameters.

100 / 0 |fix { 99 } |_+ 1
; returns 100
100 / 1 |fix { 99 } |_+ 1
; returns 101

assert-equal

Pure Builtin(2): Test if two values are equal. Fail if not.

assert-equal 10 10
; returns 1
assert-equal 10 20 |disarm |type?
; returns error

Functions that change values in-place

inc!

Builtin(1): Searches for a word and increments it's integer value in-place.

a: 100 , inc! 'a
; returns 101
a: 100 , inc! 'a , a
; returns 101

change!

Builtin(2): Searches for a word and changes it's value in-place. If value changes returns true otherwise false

a: 1 change! 2 'a
; returns 1
a: 2 change! 2 'a
; returns 0

Functions that change values in-place are used more rarely in Rye and have ! at the end.

remove-last!

Builtin(1): Accepts Block and returns the next value and removes it from the Block.

b: { 1 2 3 } , remove-last! 'b , b
; returns { 1 2 }

append!

Builtin(2): Accepts Rye value and Tagword with a Block or String. Appends Rye value to Block/String in place, also returns it .

b: { 1 2 3 } , append! 4 'b , b
; returns { 1 2 3 4 }
b: { 1 2 3 } , append! { 4 5 } 'b , b
; returns { 1 2 3 { 4 5 } }

change\ nth!

Builtin(3): Accepts a Block or List, Integer n and a value. Changes the n-th value in the Block in place. Also returns the new series.

b: { 1 4 3 } , change\nth! b 2 4
; returns { 1 4 3 }
b: { 1 { 4 5 } 3 } , change\nth! b 2 { 4 5 }
; returns { 1 { 4 5 } 3 }
b: list { 1 2 3 } , change\nth! b 2 4
; returns L[ 1  4  3 ]
b: list { 1 2 3 } , change\nth! b 2 list { 4 5 }
; returns L[ 1  L[ 4  5 ]  3 ]
try { b: { 1 2 3 } , change\nth! b 4 0 } |type?
; returns error
try { b: list { 1 2 3 } , change\nth! b 4 0 } |type?
; returns error

sort!

Builtin(2): Accepts Rye value and Tagword with a Block or String. Appends Rye value to Block/String in place, also returns it .

b: { 1 2 4 7 } , sort! b , b
; returns { 1 2 4 7 }

reverse!

Builtin(2): Accepts Rye value and Tagword with a Block or String. Appends Rye value to Block/String in place, also returns it .