Janet Core API

Version 0.4.1-41bb6a9

Generated March 14, 2019 at 22:30:30


%

cfunction

(% dividend divisor)

Returns the remainder of dividend / divisor.


%=

macro

(%= x n)

Shorthand for (set x (% x n)).

core.janet (4568:4640)

*

function

(* & xs)

Returns the product of all elements in xs. If xs is empty, returns 1.


*=

macro

(*= x n)

Shorthand for (set x (* x n)).

core.janet (4420:4492)

*doc-width*

var (number)

Width in columns to print documentation.

core.janet (34621:34687)

*env*

var (table)

The current environment.

core.janet (108:150)

+

function

(+ & xs)

Returns the sum of all xs. xs must be integers or real numbers only. If xs is empty, return 0.


++

macro

(++ x)

Increments the var x by 1.

core.janet (4144:4210)

+=

macro

(+= x n)

Increments the var x by n.

core.janet (4280:4348)

-

function

(- & xs)

Returns the difference of xs. If xs is empty, returns 0. If xs has one element, returns the negative value of that element. Otherwise, returns the first element in xs minus the sum of the rest of the elements.


--

macro

(-- x)

Decrements the var x by 1.

core.janet (4212:4278)

-=

macro

(-= x n)

Decrements the var x by n.

core.janet (4350:4418)

->

macro

(-> x & forms)

Threading macro. Inserts x as the second value in the first form in forms, and inserts the modified first form into the second form in the same manner, and so on. Useful for expressing pipelines of data.

core.janet (22479:22956)

->>

macro

(->> x & forms)

Threading macro. Inserts x as the last value in the first form in forms, and inserts the modified first form into the second form in the same manner, and so on. Useful for expressing pipelines of data.

core.janet (22959:23438)

-?>

macro

(-?> x & forms)

Short circuit threading macro. Inserts x as the last value in the first form in forms, and inserts the modified first form into the second form in the same manner, and so on. The pipeline will return nil if an intermediate value is nil. Useful for expressing pipelines of data.

core.janet (23441:24050)

-?>>

macro

(-?>> x & forms)

Threading macro. Inserts x as the last value in the first form in forms, and inserts the modified first form into the second form in the same manner, and so on. The pipeline will return nil if an intermediate value is nil. Useful for expressing pipelines of data.

core.janet (24053:24652)

/

function

(/ & xs)

Returns the quotient of xs. If xs is empty, returns 1. If xs has one value x, returns the reciprocal of x. Otherwise return the first value of xs repeatedly divided by the remaining values. Division by two integers uses truncating division.


/=

macro

(/= x n)

Shorthand for (set x (/ x n)).

core.janet (4494:4566)

<

function

(< & xs)

Check if xs is in numerically ascending order. Returns a boolean.


<=

function

(<= & xs)

Check if xs is in numerically non-descending order. Returns a boolean.


=

function

(= & xs)

Returns true if all values in xs are the same, false otherwise.


==

function

(== & xs)

Check if all values in xs are numerically equal (4.0 == 4). Returns a boolean.


>

function

(> & xs)

Check if xs is in numerically descending order. Returns a boolean.


>=

function

(>= & xs)

Check if xs is in numerically non-ascending order. Returns a boolean.


abstract?

cfunction

(abstract? x)

Check if x is an abstract type.


all

function

(all pred xs)

Returns true if all xs are truthy, otherwise the first false or nil value.

core.janet (38668:38841)

all-bindings

function

(all-bindings &opt env)

Get all symbols available in the current environment.

core.janet (51507:51863)

and

macro

(and & forms)

Evaluates to the last argument if all preceding elements are true, otherwise evaluates to false.

core.janet (7476:7803)

apply

function

(apply f & args)

Applies a function to a variable number of arguments. Each element in args is used as an argument to f, except the last element in args, which is expected to be an array-like. Each element in this last argument is then also pushed as an argument to f. For example:

    (apply + 1000 (range 10))

sums the first 10 integers and 1000.)


array

cfunction

(array & items)

Create a new array that contains items. Returns the new array.


array/concat

cfunction

(array/concat arr & parts)

Concatenates a variadic number of arrays (and tuples) into the first argument which must an array. If any of the parts are arrays or tuples, their elements will be inserted into the array. Otherwise, each part in parts will be appended to arr in order. Return the modified array arr.


array/ensure

cfunction

(array/ensure arr capacity)

Ensures that the memory backing the array has enough memory for capacity items. Capacity must be an integer. If the backing capacity is already enough, then this function does nothing. Otherwise, the backing memory will be reallocated so that there is enough space.


array/insert

cfunction

(array/insert arr at & xs)

Insert all of xs into array arr at index at. at should be an integer 0 and the length of the array. A negative value for at will index from the end of the array, such that inserting at -1 appends to the array. Returns the array.


array/new

cfunction

(array/new capacity)

Creates a new empty array with a pre-allocated capacity. The same as (array) but can be more efficient if the maximum size of an array is known.


array/peek

cfunction

(array/peek arr)

Returns the last element of the array. Does not modify the array.


array/pop

cfunction

(array/pop arr)

Remove the last element of the array and return it. If the array is empty, will return nil. Modifies the input array.


array/push

cfunction

(array/push arr x)

Insert an element in the end of an array. Modifies the input array and returns it.


array/remove

cfunction

(array/remove arr at [, n=1])

Remove up to n elements starting at index at in array arr. at can index from the end of the array with a negative index, and n must be a non-negative integer. Returns the array.


array/slice

cfunction

(array/slice arrtup [, start=0 [, end=(length arrtup)]])

Takes a slice of array or tuple from start to end. The range is half open, [start, end). Indexes can also be negative, indicating indexing from the end of the end of the array. By default, start is 0 and end is the length of the array. Returns a new array.


array?

function

(array? x)

Check if x is an array.

core.janet (2890:2952)

as->

macro

(as-> x as & forms)

Thread forms together, replacing as in forms with the value of the previous form. The first for is the value x. Returns the last value.

core.janet (25592:25943)

as?->

macro

(as?-> x as & forms)

Thread forms together, replacing as in forms with the value of the previous form. The first for is the value x. If any intermediate values are falsey, return nil; otherwise, returns the last value.

core.janet (25946:26365)

asm

cfunction

(asm assembly)

Returns a new function that is the compiled result of the assembly.
The syntax for the assembly can be found on the janet wiki. Will throw an
error on invalid assembly.


bad-compile

function

(bad-compile msg macrof where)

Default handler for a compile error.

core.janet (40796:40992)

bad-parse

function

(bad-parse p where)

Default handler for a parse error.

core.janet (40514:40793)

band

function

(band & xs)

Returns the bit-wise and of all values in xs. Each x in xs must be an integer.


blshift

function

(blshift x & shifts)

Returns the value of x bit shifted left by the sum of all values in shifts. x and each element in shift must be an integer.


bnot

function

(bnot x)

Returns the bit-wise inverse of integer x.


boolean?

function

(boolean? x)

Check if x is a boolean.

core.janet (3017:3084)

bor

function

(bor & xs)

Returns the bit-wise or of all values in xs. Each x in xs must be an integer.


brshift

function

(brshift x & shifts)

Returns the value of x bit shifted right by the sum of all values in shifts. x and each element in shift must be an integer.


brushift

function

(brushift x & shifts)

Returns the value of x bit shifted right by the sum of all values in shifts. x and each element in shift must be an integer. The sign of x is not preserved, so for positive shifts the return value will always be positive.


buffer

cfunction

(buffer & xs)

Creates a new buffer by concatenating values together. Values are converted to bytes via describe if they are not byte sequences. Returns the new buffer.


buffer/bit

cfunction

(buffer/bit buffer index)

Gets the bit at the given bit-index. Returns true if the bit is set, false if not.


buffer/bit-clear

cfunction

(buffer/bit-clear buffer index)

Clears the bit at the given bit-index. Returns the buffer.


buffer/bit-set

cfunction

(buffer/bit-set buffer index)

Sets the bit at the given bit-index. Returns the buffer.


buffer/bit-toggle

cfunction

(buffer/bit-toggle buffer index)

Toggles the bit at the given bit index in buffer. Returns the buffer.


buffer/blit

cfunction

(buffer/blit dest src [, dest-start=0 [, src-start=0 [, src-end=-1]]])

Insert the contents of src into dest. Can optionally take indices that indicate which part of src to copy into which part of dest. Indices can be negative to index from the end of src or dest. Returns dest.


buffer/clear

cfunction

(buffer/clear buffer)

Sets the size of a buffer to 0 and empties it. The buffer retains its memory so it can be efficiently refilled. Returns the modified buffer.


buffer/format

cfunction

(buffer/format buffer format & args)

Snprintf like functionality for printing values into a buffer. Returns the modified buffer.


buffer/new

cfunction

(buffer/new capacity)

Creates a new, empty buffer with enough memory for capacity bytes. Returns a new buffer.


buffer/new-filled

cfunction

(buffer/new-filled count [, byte=0])

Creates a new buffer of length count filled with byte. Returns the new buffer.


buffer/popn

cfunction

(buffer/popn buffer n)

Removes the last n bytes from the buffer. Returns the modified buffer.


buffer/push-byte

cfunction

(buffer/push-byte buffer x)

Append a byte to a buffer. Will expand the buffer as necessary. Returns the modified buffer. Will throw an error if the buffer overflows.


buffer/push-string

cfunction

(buffer/push-string buffer str)

Push a string onto the end of a buffer. Non string values will be converted to strings before being pushed. Returns the modified buffer. Will throw an error if the buffer overflows.


buffer/push-word

cfunction

(buffer/push-word buffer x)

Append a machine word to a buffer. The 4 bytes of the integer are appended in twos complement, big endian order, unsigned. Returns the modified buffer. Will throw an error if the buffer overflows.


buffer/slice

cfunction

(buffer/slice bytes [, start=0 [, end=(length bytes)]])

Takes a slice of a byte sequence from start to end. The range is half open, [start, end). Indexes can also be negative, indicating indexing from the end of the end of the array. By default, start is 0 and end is the length of the buffer. Returns a new buffer.


buffer?

function

(buffer? x)

Check if x is a buffer.

core.janet (2537:2601)

bxor

function

(bxor & xs)

Returns the bit-wise xor of all values in xs. Each in xs must be an integer.


bytes?

function

(bytes? x)

Check if x is a string, symbol, or buffer.

core.janet (3086:3255)

case

macro

(case dispatch & pairs)

Select the body that equals the dispatch value. When pairs has an odd number of arguments, the last is the default expression. If no match is found, returns nil

core.janet (5764:6371)

cfunction?

function

(cfunction? x)

Check if x a cfunction.

core.janet (2695:2765)

comment

macro

(comment)

Ignores the body of the comment.

core.janet (4818:4877)

comp

function

(comp & functions)

Takes multiple functions and returns a function that is the composition of those functions.

core.janet (15531:16014)

compile

cfunction

(compile ast env [, source])

Compiles an Abstract Syntax Tree (ast) into a janet function. Pair the compile function with parsing functionality to implement eval. Returns a janet function and does not modify ast. Throws an error if the ast cannot be compiled.


complement

function

(complement f)

Returns a function that is the complement to the argument.

core.janet (16092:16200)

cond

macro

(cond & pairs)

Evaluates conditions sequentially until the first true condition is found, and then executes the corresponding body. If there are an odd number of forms, the last expression is executed if no forms are matched. If there are no matches, return nil.

core.janet (5247:5761)

coro

macro

(coro & body)

A wrapper for making fibers. Same as (fiber/new (fn [] ...body)).

core.janet (14001:14138)

count

function

(count pred ind)

Count the number of items in ind for which (pred item) is true.

core.janet (19491:19671)

debug

function

(debug)

Throws a debug signal that can be caught by a parent fiber and used to inspect the running state of the current fiber. Returns nil.


debug/arg-stack

cfunction

(debug/arg-stack fiber)

Gets all values currently on the fiber's argument stack. Normally, this should be empty unless the fiber signals while pushing arguments to make a function call. Returns a new array.


debug/break

cfunction

(debug/break source byte-offset)

Sets a breakpoint with source a key at a given byte offset. An offset of 0 is the first byte in a file. Will throw an error if the breakpoint location cannot be found. For example

    (debug/break "core.janet" 1000)

wil set a breakpoint at the 1000th byte of the file core.janet.


debug/fbreak

cfunction

(debug/fbreak fun [,pc=0])

Set a breakpoint in a given function. pc is an optional offset, which is in bytecode instructions. fun is a function value. Will throw an error if the offset is too large or negative.


debug/lineage

cfunction

(debug/lineage fib)

Returns an array of all child fibers from a root fiber. This function is useful when a fiber signals or errors to an ancestor fiber. Using this function, the fiber handling the error can see which fiber raised the signal. This function should be used mostly for debugging purposes.


debug/stack

cfunction

(debug/stack fib)

Gets information about the stack as an array of tables. Each table in the array contains information about a stack frame. The top most, current stack frame is the first table in the array, and the bottom most stack frame is the last value. Each stack frame contains some of the following attributes:

    :c - true if the stack frame is a c function invocation
    :column - the current source column of the stack frame
    :function - the function that the stack frame represents
    :line - the current source line of the stack frame
    :name - the human friendly name of the function
    :pc - integer indicating the location of the program counter
    :source - string with the file path or other identifier for the source code
    :slots - array of all values in each slot
    :tail - boolean indicating a tail call


debug/stacktrace

cfunction

(debug/stacktrace fiber err)

Prints a nice looking stacktrace for a fiber. The error message err must be passed to the function as fiber's do not keep track of the last error they have thrown. Returns the fiber.


debug/unbreak

cfunction

(debug/unbreak source byte-offset)

Remove a breakpoint with a source key at a given byte offset. An offset of 0 is the first byte in a file. Will throw an error if the breakpoint cannot be found.


debug/unfbreak

cfunction

(debug/unfbreak fun [,pc=0])

Unset a breakpoint set with debug/fbreak.


dec

function

(dec x)

Returns x - 1.

core.janet (4104:4142)

deep-not=

function

(deep-not= x y)

Like not=, but mutable types (arrays, tables, buffers) are considered equal if they have identical structure. Much slower than not=.

core.janet (39048:39611)

deep=

function

(deep= x y)

Like =, but mutable types (arrays, tables, buffers) are considered equal if they have identical structure. Much slower than =.

core.janet (39614:39790)

def-

macro

(def- name & more)

Define a private value that will not be exported.

core.janet (1473:1588)

default

macro

(default sym val)

Define a default value for an optional argument. Expands to (def sym (if (= nil sym) val sym))

core.janet (4643:4815)

defglobal

function

(defglobal name value)

Dynamically create a global def.

core.janet (1591:1728)

defmacro

macro

(defmacro name & more)

Define a macro.

core.janet (1123:1212)

defmacro-

macro

(defmacro- name & more)

Define a private macro that will not be exported.

core.janet (1215:1345)

defn

macro

(def name & more)

Define a function. Equivalent to (def name (fn name [args] ...)).

core.janet (153:1120)

defn-

macro

(defn- name & more)

Define a private function that will not be exported.

core.janet (1348:1470)

describe

cfunction

(describe x)

Returns a string that is a human readable description of a value x.


dictionary?

function

(dictionary? x)

Check if x a table or struct.

core.janet (3257:3368)

disasm

cfunction

(disasm func)

Returns assembly that could be used be compile the given function.
func must be a function, not a c function. Will throw on error on a badly
typed argument.


distinct

function

(distinct xs)

Returns an array of the deduplicated values in xs.

core.janet (29466:29659)

doc

macro

(doc sym)

Shows documentation for the given symbol.

core.janet (36248:36338)

doc*

function

(doc* env sym)

Get the documentation for a symbol in a given environment.

core.janet (35518:36245)

doc-format

function

(doc-format text)

Reformat text to wrap at a given line.

core.janet (34690:35515)

drop-until

function

(drop-until pred ind)

Given a predicate, remove elements from an indexed type that satisfy the predicate, and abort on first failure. Returns a new array.

core.janet (21622:21863)

drop-while

function

(drop-while pred ind)

Same as (drop-until (complement pred) ind).

core.janet (21866:21980)

each

macro

(each x ind & body)

Loop over each value in ind. Returns nil.

core.janet (11268:11374)

empty?

function

(empty? xs)

Check if xs is empty.

core.janet (3632:3691)

env-lookup

cfunction

(env-lookup env)

Creates a forward lookup table for unmarshalling from an environment. To create a reverse lookup table, use the invert function to swap keys and values in the returned table.


error

function

(error e)

Throws an error e that can be caught and handled by a parent fiber.


eval

function

(eval form &opt env)

Evaluates a form in the current environment. If more control over the environment is needed, use run-context.

core.janet (44495:44766)

eval-string

function

(eval-string str &opt env)

Evaluates a string in the current environment. If more control over the environment is needed, use run-context.

core.janet (43558:44492)

even?

function

(even? x)

Check if x is even.

core.janet (1889:1941)

every?

function

(every? ind)

Returns true if each value in is truthy, otherwise the first falsey value.

core.janet (26490:26673)

extreme

function

(extreme order args)

Returns the most extreme value in args based on the function order. order should take two values and return true or false (a comparison). Returns nil if args is empty.

core.janet (16203:16479)

false?

function

(false? x)

Check if x is false.

core.janet (3532:3583)

fiber/current

cfunction

(fiber/current)

Returns the currently running fiber.


fiber/maxstack

cfunction

(fiber/maxstack fib)

Gets the maximum stack size in janet values allowed for a fiber. While memory for the fiber's stack is not allocated up front, the fiber will not allocated more than this amount and will throw a stack-overflow error if more memory is needed.


fiber/new

cfunction

(fiber/new func [,sigmask])

Create a new fiber with function body func. Can optionally take a set of signals to block from the current parent fiber when called. The mask is specified as a keyword where each character is used to indicate a signal to block. The default sigmask is :y. For example,

    (fiber/new myfun :e123)

blocks error signals and user signals 1, 2 and 3. The signals are as follows:

    a - block all signals
    d - block debug signals
    e - block error signals
    u - block user signals
    y - block yield signals
    0-9 - block a specific user signal


fiber/setmaxstack

cfunction

(fiber/setmaxstack fib maxstack)

Sets the maximum stack size in janet values for a fiber. By default, the maximum stack size is usually 8192.


fiber/status

cfunction

(fiber/status fib)

Get the status of a fiber. The status will be one of:

    :dead - the fiber has finished
    :error - the fiber has errored out
    :debug - the fiber is suspended in debug mode
    :pending - the fiber has been yielded
    :user(0-9) - the fiber is suspended by a user signal
    :alive - the fiber is currently running and cannot be resumed
    :new - the fiber has just been created and not yet run


fiber?

function

(fiber? x)

Check if x is a fiber.

core.janet (2273:2334)

file/close

cfunction

(file/close f)

Close a file and release all related resources. When you are done reading a file, close it to prevent a resource leak and let other processes read the file.


file/flush

cfunction

(file/flush f)

Flush any buffered bytes to the file system. In most files, writes are buffered for efficiency reasons. Returns the file handle.


file/open

cfunction

(file/open path [,mode])

Open a file. path is an absolute or relative path, and mode is a set of flags indicating the mode to open the file in. mode is a keyword where each character represents a flag. If the file cannot be opened, returns nil, otherwise returns the new file handle. Mode flags:

    r - allow reading from the file
    w - allow writing to the file
    a - append to the file
    b - open the file in binary mode (rather than text mode)
    + - append to the file instead of overwriting it


file/popen

cfunction

(file/popen path [,mode])

Open a file that is backed by a process. The file must be opened in either the :r (read) or the :w (write) mode. In :r mode, the stdout of the process can be read from the file. In :w mode, the stdin of the process can be written to. Returns the new file.


file/read

cfunction

(file/read f what [,buf])

Read a number of bytes from a file into a buffer. A buffer can be provided as an optional fourth argument, otherwise a new buffer is created. 'what' can either be an integer or a keyword. Returns the buffer with file contents. Values for 'what':

    :all - read the whole file
    :line - read up to and including the next newline character
    n (integer) - read up to n bytes from the file


file/seek

cfunction

(file/seek f [,whence [,n]])

Jump to a relative location in the file. 'whence' must be one of

    :cur - jump relative to the current file location
    :set - jump relative to the beginning of the file
    :end - jump relative to the end of the file

By default, 'whence' is :cur. Optionally a value n may be passed for the relative number of bytes to seek in the file. n may be a real number to handle large files of more the 4GB. Returns the file handle.


file/write

cfunction

(file/write f bytes)

Writes to a file. 'bytes' must be string, buffer, or symbol. Returns the file.


filter

function

(filter pred ind)

Given a predicate, take only elements from an array or tuple for which (pred element) is truthy. Returns a new array.

core.janet (19250:19488)

find

function

(find pred ind)

Find the first value in an indexed collection that satisfies a predicate. Returns nil if not found. Note their is no way to differentiate a nil from the indexed collection and a not found. Consider find-index if this is an issue.

core.janet (20927:21253)

find-index

function

(find-index pred ind)

Find the index of indexed type for which pred is true. Returns nil if not found.

core.janet (20631:20924)

first

function

(first xs)

Get the first element from an indexed data structure.

core.janet (16938:17027)

flatten

function

(flatten xs)

Takes a nested array (tree), and returns the depth first traversal of that array. Returns a new array.

core.janet (29919:30072)

flatten-into

function

(flatten-into into xs)

Takes a nested array (tree), and appends the depth first traversal of that array to an array 'into'. Returns array into.

core.janet (29662:29916)

for

macro

(for i start stop & body)

Do a c style for loop for side effects. Returns nil.

core.janet (11130:11265)

frequencies

function

(frequencies ind)

Get the number of occurrences of each value in a indexed structure.

core.janet (28939:29140)

function?

function

(function? x)

Check if x is a function (not a cfunction).

core.janet (2603:2693)

gccollect

cfunction

(gccollect)

Run garbage collection. You should probably not call this manually.


gcinterval

cfunction

(gcinterval)

Returns the integer number of bytes to allocate before running an iteration of garbage collection.


gcsetinterval

cfunction

(gcsetinterval interval)

Set an integer number of bytes to allocate before running garbage collection. Low valuesi for interval will be slower but use less memory. High values will be faster but use more memory.


generate

macro

(generate head & body)

Create a generator expression using the loop syntax. Returns a fiber that yields all values inside the loop in order. See loop for details.

core.janet (13762:13998)

gensym

cfunction

(gensym)

Returns a new symbol that is unique across the runtime. This means it will not collide with any already created symbols during compilation, so it can be used in macros to generate automatic bindings.


get

function

(get ds key)

Get a value from any associative data structure. Arrays, tuples, tables, structs, strings, symbols, and buffers are all associative and can be used with get. Order structures, name arrays, tuples, strings, buffers, and symbols must use integer keys. Structs and tables can take any value as a key except nil and return a value except nil. Byte sequences will return integer representations of bytes as result of a get call.


getline

cfunction

(getline [, prompt="" [, buffer=@""]])

Reads a line of input into a buffer, including the newline character, using a prompt. Returns the modified buffer. Use this function to implement a simple interface for a terminal program.


hash

cfunction

(hash value)

Gets a hash value for any janet value. The hash is an integer can be used as a cheap hash function for all janet objects. If two values are strictly equal, then they will have the same hash value.


idempotent?

function

(idempotent? x)

Check if x is a value that evaluates to itself when compiled.

core.janet (3693:3989)

identity

function

(identity x)

A function that returns its first argument.

core.janet (16017:16089)

if-let

macro

(if-let bindings tru &opt fal)

Make multiple bindings, and if all are truthy, evaluate the tru form. If any are false or nil, evaluate the fal form. Bindings have the same syntax as the let macro.

core.janet (14397:15411)

if-not

macro

(if-not condition exp-1 &opt exp-2)

Shorthand for (if (not ...

core.janet (4880:4992)

import

macro

(import path & args)

Import a module. First requires the module, and then merges its symbols into the current environment, prepending a given prefix as needed. (use the :as or :prefix option to set a prefix). If no prefix is provided, use the name of the module as a prefix. One can also use :export true to re-export the imported symbols.

core.janet (50104:50654)

import*

function

(import* env path & args)

Import a module into a given environment table. This is the functional form of (import ...) that expects and explicit environment table.

core.janet (49596:50101)

inc

function

(inc x)

Returns x + 1.

core.janet (4064:4102)

indexed?

function

(indexed? x)

Check if x is an array or tuple.

core.janet (3370:3480)

interleave

function

(interleave & cols)

Returns an array of the first elements of each col, then the second, etc.

core.janet (29143:29463)

interpose

function

(interpose sep ind)

Returns a sequence of the elements of ind separated by sep. Returns a new array.

core.janet (30315:30621)

invert

function

(invert ds)

Returns a table of where the keys of an associative data structure are the values, and the values of the keys. If multiple keys have the same value, one key will be ignored.

core.janet (26941:27213)

janet/build

string

The build identifier of the running janet program.


janet/version

string

The version number of the running janet program.


juxt

macro

(juxt & funs)

Macro form of juxt*. Same behavior but more efficient.

core.janet (22231:22476)

juxt*

function

(juxt* & funs)

Returns the juxtaposition of functions. In other words, ((juxt* a b c) x) evaluates to ((a x) (b x) (c x)).

core.janet (21983:22228)

keep

function

(keep pred ind)

Given a predicate, take only elements from an array or tuple for which (pred element) is truthy. Returns a new array of truthy predicate results.

core.janet (19674:19943)

keys

function

(keys x)

Get the keys of an associative data structure.

core.janet (28297:28497)

keyword

cfunction

(keyword & xs)

Creates a keyword by concatenating values together. Values are converted to bytes via describe if they are not byte sequences. Returns the new keyword.


keyword?

function

(keyword? x)

Check if x is a keyword.

core.janet (2468:2535)

kvs

function

(kvs dict)

Takes a table or struct and returns and array of key value pairs like @[k v k v ...]. Returns a new array.

core.janet (30075:30312)

last

function

(last xs)

Get the last element from an indexed data structure.

core.janet (17030:17133)

length

function

(length ds)

Returns the length or count of a data structure in constant time as an integer. For structs and tables, returns the number of key-value pairs in the data structure.


let

macro

(let bindings & body)

Create a scope and bind values to symbols. Each pair in bindings is assigned as if with def, and the body of the let form returns the last value.

core.janet (6374:6866)

load-image

function

(load-image image)

The inverse operation to make-image. Returns an environment.

core.janet (44940:45069)

loop

macro

(loop head & body)

A general purpose loop macro. This macro is similar to the Common Lisp loop macro, although intentionally much smaller in scope. The head of the loop should be a tuple that contains a sequence of either bindings or conditionals. A binding is a sequence of three values that define something to loop over. They are formatted like:

    binding :verb object/expression

Where binding is a binding as passed to def, :verb is one of a set of keywords, and object is any janet expression. The available verbs are:

    :iterate - repeatedly evaluate and bind to the expression while it is truthy.
    :range - loop over a range. The object should be two element tuple with a start and end value, and an optional postive step. The range is half open, [start, end).
    :down - Same as range, but loops in reverse.
    :keys - Iterate over the keys in a data structure.
    :pairs - Iterate over the keys value pairs in a data structure.
    :in - Iterate over the values in an indexed data structure or byte sequence.
    :generate - Iterate over values yielded from a fiber. Can be paired with the generator function for the producer/consumer pattern.

loop also accepts conditionals to refine the looping further. Conditionals are of the form:

    :modifier argument

where :modifier is one of a set of keywords, and argument is keyword dependent. :modifier can be one of:

    :while expression - breaks from the loop if expression is falsey.
    :let bindings - defines bindings inside the loop as passed to the let macro.
    :before form - evaluates a form for a side effect before of the next inner loop.
    :after form - same as :before, but the side effect happens after the next inner loop.
    :repeat n - repeats the next inner loop n times.
    :when condition - only evaluates the loop body when condition is true.

The loop macro always evaluates to nil.

core.janet (11377:13371)

macex

function

(macex x)

Expand macros completely.

core.janet (39793:40088)

macex1

function

(macex1 x)

Expand macros in a form, but do not recursively expand macros.

core.janet (36378:38665)

make-env

function

(make-env &opt parent)

Create a new environment table. The new environment will inherit bindings from the parent environment, but new bindings will not pollute the parent environment.

core.janet (40221:40511)

make-image

function

(make-image env)

Create an image from an environment returned by require. Returns the image source as a string.

core.janet (44769:44937)

map

function

(map f & inds)

Map a function over every element in an indexed data structure and return an array of the results.

core.janet (18216:19053)

mapcat

function

(mapcat f ind)

Map a function over every element in an array or tuple and use array to concatenate the results.

core.janet (19056:19247)

marshal

cfunction

(marshal x [,reverse-lookup [,buffer]])

Marshal a janet value into a buffer and return the buffer. The buffer can the later be unmarshalled to reconstruct the initial value. Optionally, one can pass in a reverse lookup table to not marshal aliased values that are found in the table. Then a forwardlookup table can be used to recover the original janet value when unmarshalling.


match

macro

(match x & cases)

Pattern matching. Match an expression x against any number of cases. Easy case is a pattern to match against, followed by an expression to evaluate to if that case is matched. A pattern that is a symbol will match anything, binding x's value to that symbol. An array will match only if all of it's elements match the corresponding elements in x. A table or struct will match if all values match with the corresponding values in x. A tuple pattern will match if it's first element matches, and the following elements are treated as predicates and are true. Any other value pattern will only match if it is equal to x.

core.janet (33467:34506)

math/abs

cfunction

(math/abs x)

Return the absolute value of x.


math/acos

cfunction

(math/acos x)

Returns the arccosine of x.


math/asin

cfunction

(math/asin x)

Returns the arcsine of x.


math/atan

cfunction

(math/atan x)

Returns the arctangent of x.


math/atan2

cfunction

(math/atan2 y x)

Return the arctangent of y/x. Works even when x is 0.


math/ceil

cfunction

(math/ceil x)

Returns the smallest integer value number that is not less than x.


math/cos

cfunction

(math/cos x)

Returns the cosine of x.


math/cosh

cfunction

(math/cosh x)

Return the hyperbolic cosine of x.


math/e

number

The base of the natural log.


math/exp

cfunction

(math/exp x)

Returns e to the power of x.


math/floor

cfunction

(math/floor x)

Returns the largest integer value number that is not greater than x.


math/inf

number

The number representing positive infinity


math/log

cfunction

(math/log x)

Returns log base 2 of x.


math/log10

cfunction

(math/log10 x)

Returns log base 10 of x.


math/pi

number

The value pi.


math/pow

cfunction

(math/pow a x)

Return a to the power of x.


math/random

cfunction

(math/random)

Returns a uniformly distributed random number between 0 and 1.


math/seedrandom

cfunction

(math/seedrandom seed)

Set the seed for the random number generator. 'seed' should be an an integer.


math/sin

cfunction

(math/sin x)

Returns the sine of x.


math/sinh

cfunction

(math/sinh x)

Return the hyperbolic sine of x.


math/sqrt

cfunction

(math/sqrt x)

Returns the square root of x.


math/tan

cfunction

(math/tan x)

Returns the tangent of x.


math/tanh

cfunction

(math/tanh x)

Return the hyperbolic tangent of x.


max

function

(max & args)

Returns the numeric maximum of the arguments.

core.janet (16482:16569)

max-order

function

(max-order & args)

Returns the maximum of the arguments according to a total order over all values.

core.janet (16662:16797)

merge

function

(merge & colls)

Merges multiple tables/structs to one. If a key appears in more than one collection, then later values replace any previous ones. Returns a new table.

core.janet (27996:28294)

merge-into

function

(merge-into tab & colls)

Merges multiple tables/structs into a table. If a key appears in more than one collection, then later values replace any previous ones. Returns the original table.

core.janet (27707:27993)

meta

macro

(meta & args)

Add metadata to the current environment.

core.janet (51358:51504)

min

function

(min & args)

Returns the numeric minimum of the arguments.

core.janet (16572:16659)

min-order

function

(min-order & args)

Returns the minimum of the arguments according to a total order over all values.

core.janet (16800:16935)

module/*syspath*

var (string)

The path where globally installed libraries are located. The default is set at build time and is /usr/local/lib/janet on linux/posix, and on Windows is C:/Janet/Library.

core.janet (46043:46277)

module/cache

table

Table mapping loaded module identifiers to their environments.

core.janet (47430:47520)

module/find

function

(module/find path)

Try to match a module or path name from the patterns in module/paths. Returns a tuple (fullpath kind) where the kind is one of :source, :native, or image if the module is found, otherise a tuple with nil followed by an error message.

core.janet (46365:47402)

module/loading

table

Table mapping currently loading modules to true. Used to prevent circular dependencies.

core.janet (47523:47642)

module/paths

array

The list of paths to look for modules. The following substitutions are preformed on each path. :sys: becomes module/*syspath*, :name: becomes the last part of the module name after the last /, and :all: is the module name literally. :native: becomes the dynamic library file extension, usually dll or so. Each element is a two element tuple, containing the path template and a keyword :source, :native, or :image indicating how require should load files found at these paths.

core.janet (45072:46040)

native

cfunction

(native path [,env])

Load a native module from the given path. The path must be an absolute or relative path on the file system, and is usually a .so file on Unix systems, and a .dll file on Windows. Returns an environment table that contains functions and other values from the native module.


neg?

function

(neg? x)

Check if x is less than 0.

core.janet (2101:2152)

cfunction

(next dict key)

Gets the next key in a struct or table. Can be used to iterate through the keys of a data structure in an unspecified order. Keys are guaranteed to be seen only once per iteration if they data structure is not mutated during iteration. If key is nil, next returns the first key. If next returns nil, there are no more keys to iterate through.


nil?

function

(nil? x)

Check if x is nil.

core.janet (3585:3630)

not

cfunction

(not x)

Returns the boolean inverse of x.


not=

function

(not= & xs)

Return true if any values in xs are not equal, otherwise false.


not==

function

(not== & xs)

Check if any values in xs are not numerically equal (3.0 not== 4). Returns a boolean.


number?

function

(number? x)

Check if x is a number.

core.janet (2207:2271)

odd?

function

(odd? x)

Check if x is odd.

core.janet (1943:1995)

one?

function

(one? x)

Check if x is equal to 1.

core.janet (2154:2205)

or

macro

(or & forms)

Evaluates to the last argument if all preceding elements are false, otherwise evaluates to true.

core.janet (7806:8278)

order<

function

(order< & xs)

Check if xs is strictly increasing according to a total order over all values. Returns a boolean.


order<=

function

(order<= & xs)

Check if xs is not decreasing according to a total order over all values. Returns a boolean.


order>

function

(order> & xs)

Check if xs is strictly descending according to a total order over all values. Returns a boolean.


order>=

function

(order>= & xs)

Check if xs is not increasing according to a total order over all values. Returns a boolean.


os/clock

cfunction

(os/clock)

Return the number of seconds since some fixed point in time. The clock is guaranteed to be non decreasing in real time.


os/cwd

cfunction

(os/cwd)

Returns the current working directory.


os/date

cfunction

(os/date [,time])

Returns the given time as a date struct, or the current time if no time is given. Returns a struct with following key values. Note that all numbers are 0-indexed.

    :seconds - number of seconds [0-61]
    :minutes - number of minutes [0-59]
    :seconds - number of hours [0-23]
    :month-day - day of month [0-30]
    :month - month of year [0, 11]
    :year - years since year 0 (e.g. 2019)
    :week-day - day of the week [0-6]
    :year-day - day of the year [0-365]
    :dst - If Day Light Savings is in effect


os/execute

cfunction

(os/execute program & args)

Execute a program on the system and pass it string arguments. Returns the exit status of the program.


os/exit

cfunction

(os/exit x)

Exit from janet with an exit code equal to x. If x is not an integer, the exit with status equal the hash of x.


os/getenv

cfunction

(os/getenv variable)

Get the string value of an environment variable.


os/setenv

cfunction

(os/setenv variable value)

Set an environment variable.


os/shell

cfunction

(os/shell str)

Pass a command string str directly to the system shell.


os/sleep

cfunction

(os/sleep nsec)

Suspend the program for nsec seconds. 'nsec' can be a real number. Returns nil.


os/time

cfunction

(os/time)

Get the current time expressed as the number of seconds since January 1, 1970, the Unix epoch. Returns a real number.


os/which

cfunction

(os/which)

Check the current operating system. Returns one of:

    :windows - Microsoft Windows
    :macos - Apple macos
    :posix - A POSIX compatible system (default)


pairs

function

(pairs x)

Get the values of an associative data structure.

core.janet (28715:28936)

parser/byte

cfunction

(parser/byte parser b)

Input a single byte into the parser byte stream. Returns the parser.


parser/consume

cfunction

(parser/consume parser bytes [, index])

Input bytes into the parser and parse them. Will not throw errors if there is a parse error. Starts at the byte index given by index. Returns the number of bytes read.


parser/eof

cfunction

(parser/insert parser)

Indicate that the end of file was reached to the parser. This puts the parser in the :dead state.


parser/error

cfunction

(parser/error parser)

If the parser is in the error state, returns the message associated with that error. Otherwise, returns nil. Also flushes the parser state and parser queue, so be sure to handle everything in the queue before calling parser/error.


parser/flush

cfunction

(parser/flush parser)

Clears the parser state and parse queue. Can be used to reset the parser if an error was encountered. Does not reset the line and column counter, so to begin parsing in a new context, create a new parser.


parser/has-more

cfunction

(parser/has-more parser)

Check if the parser has more values in the value queue.


parser/insert

cfunction

(parser/insert parser value)

Insert a value into the parser. This means that the parser state can be manipulated in between chunks of bytes. This would allow a user to add extra elements to arrays and tuples, for example. Returns the parser.


parser/new

cfunction

(parser/new)

Creates and returns a new parser object. Parsers are state machines that can receive bytes, and generate a stream of janet values.


parser/produce

cfunction

(parser/produce parser)

Dequeue the next value in the parse queue. Will return nil if no parsed values are in the queue, otherwise will dequeue the next value.


parser/state

cfunction

(parser/state parser)

Returns a string representation of the internal state of the parser. Each byte in the string represents a nested data structure. For example, if the parser state is '(["', then the parser is in the middle of parsing a string inside of square brackets inside parentheses. Can be used to augment a REPL prompt.


parser/status

cfunction

(parser/status parser)

Gets the current status of the parser state machine. The status will be one of:

    :pending - a value is being parsed.
    :error - a parsing error was encountered.
    :root - the parser can either read more values or safely terminate.


parser/where

cfunction

(parser/where parser)

Returns the current line number and column number of the parser's location in the byte stream as a tuple (line, column). Lines and columns are counted from 1, (the first byte is line 1, column 1) and a newline is considered ASCII 0x0A.


partial

function

(partial f & more)

Partial function application.

core.janet (26368:26487)

partition

function

(partition n ind)

Partition an indexed data structure into tuples of size n. Returns a new array.

core.janet (30624:31002)

peg/compile

cfunction

(peg/compile peg)

Compiles a peg source data structure into a <core/peg>. This will speed up matching if the same peg will be used multiple times.


peg/match

cfunction

(peg/match peg text [,start=0])

Match a Parsing Expression Grammar to a byte string and return an array of captured values. Returns nil if text does not match the language defined by peg. The syntax of PEGs are very similar to those defined by LPeg, and have similar capabilities.


pos?

function

(pos? x)

Check if x is greater than 0.

core.janet (2045:2099)

postwalk

function

(postwalk f form)

Do a post-order traversal of a data structure and call (f x) on every visitation.

core.janet (25313:25468)

pp

function

(pp x)

Pretty print to stdout.

core.janet (40091:40170)

prewalk

function

(prewalk f form)

Similar to postwalk, but do pre-order traversal.

core.janet (25471:25589)

print

cfunction

(print & xs)

Print values to the console (standard out). Value are converted to strings if they are not already. After printing all values, a newline character is printed. Returns nil.


process/args

array

Command line arguments.


product

function

(product xs)

Returns the product of xs. If xs is empty, returns 1.

core.janet (14265:14394)

put

function

(put ds key value)

Associate a key with a value in any mutable associative data structure. Indexed data structures (arrays and buffers) only accept non-negative integer keys, and will expand if an out of bounds value is provided. In an array, extra space will be filled with nils, and in a buffer, extra space will be filled with 0 bytes. In a table, putting a key that is contained in the table prototype will hide the association defined by the prototype, but will not mutate the prototype table. Putting a value nil into a table will remove the key from the table. Returns the data structure ds.


range

function

(range & args)

Create an array of values [start, end) with a given step. With one argument returns a range [0, end). With two arguments, returns a range [start, end). With three, returns a range with optional step size.

core.janet (19946:20628)

reduce

function

(reduce f init ind)

Reduce, also know as fold-left in many languages, transforms an indexed type (array, tuple) with a function to produce a value.

core.janet (17994:18213)

repl

function

(repl &opt chunks onsignal)

Run a repl. The first parameter is an optional function to call to get a chunk of source code that should return nil for end of file. The second parameter is a function that is called when a signal is caught.

core.janet (50657:51355)

require

function

(require path & args)

Require a module with the given name. Will search all of the paths in module/paths, then the path as a raw file path. Returns the new environment returned from compiling and running the file.

core.janet (47645:49593)

resume

function

(resume fiber &opt x)

Resume a new or suspended fiber and optionally pass in a value to the fiber that will be returned to the last yield in the case of a pending fiber, or the argument to the dispatch function in the case of a new fiber. Returns either the return result of the fiber's dispatch function, or the value from the next yield call in fiber.


reverse

function

(reverse t)

Reverses the order of the elements in a given array or tuple and returns a new array.

core.janet (26676:26938)

run-context

function

(run-context opts)

Run a context. This evaluates expressions of janet in an environment, and is encapsulates the parsing, compilation, and evaluation. opts is a table or struct of options. The options are as follows:

     :chunks - callback to read into a buffer - default is getline
     :on-parse-error - callback when parsing fails - default is bad-parse
     :env - the environment to compile against - default is *env*
     :source - string path of source for better errors - default is "<anonymous>"
     :on-compile-error - callback when compilation fails - default is bad-compile
     :on-status - callback when a value is evaluated - default is debug/stacktrace
     :fiber-flags - what flags to wrap the compilation fiber with. Default is :a.

core.janet (40995:43555)

scan-number

cfunction

(scan-number str)

Parse a number from a byte sequence an return that number, either and integer or a real. The number must be in the same format as numbers in janet source code. Will return nil on an invalid number.


seq

macro

(seq head & body)

Similar to loop, but accumulates the loop body into an array and returns that. See loop for details.

core.janet (13519:13759)

slurp

function

(slurp path)

Read all data from a file with name path and then close the file.

core.janet (31037:31281)

some

function

(some pred xs)

Returns false if all xs are false or nil, otherwise returns the first true value.

core.janet (38844:39045)

sort

function

(sort xs [, by])

Sort an array in-place. Uses quick-sort and is not a stable sort.

core.janet (17177:17873)

sorted

function

(sorted ind by)

Returns a new sorted array without modifying the old one.

core.janet (17876:17991)

spit

function

(spit path contents &opt mode)

Write contents to a file at path. Can optionally append to the file.

core.janet (31284:31575)

stderr

core/file

The standard error file.


stdin

core/file

The standard input file.


stdout

core/file

The standard output file.


string

cfunction

(string & parts)

Creates a string by concatenating values together. Values are converted to bytes via describe if they are not byte sequences. Returns the new string.


string/ascii-lower

cfunction

(string/ascii-lower str)

Returns a new string where all bytes are replaced with the lowercase version of themselves in ASCII. Does only a very simple case check, meaning no unicode support.


string/ascii-upper

cfunction

(string/ascii-upper str)

Returns a new string where all bytes are replaced with the uppercase version of themselves in ASCII. Does only a very simple case check, meaning no unicode support.


string/bytes

cfunction

(string/bytes str)

Returns an array of integers that are the byte values of the string.


string/check-set

cfunction

(string/check-set set str)

Checks if any of the bytes in the string set appear in the string str. Returns true if some bytes in set do appear in str, false if no bytes do.


string/find

cfunction

(string/find patt str)

Searches for the first instance of pattern patt in string str. Returns the index of the first character in patt if found, otherwise returns nil.


string/find-all

cfunction

(string/find patt str)

Searches for all instances of pattern patt in string str. Returns an array of all indices of found patterns. Overlapping instances of the pattern are not counted, meaning a byte in string will only contribute to finding at most on occurrence of pattern. If no occurrences are found, will return an empty array.


string/format

cfunction

(string/format format & values)

Similar to snprintf, but specialized for operating with janet. Returns a new string.


string/from-bytes

cfunction

(string/from-bytes byte-array)

Creates a string from an array of integers with byte values. All integers will be coerced to the range of 1 byte 0-255.


string/join

cfunction

(string/join parts [,sep])

Joins an array of strings into one string, optionally separated by a separator string sep.


string/repeat

cfunction

(string/repeat bytes n)

Returns a string that is n copies of bytes concatenated.


string/replace

cfunction

(string/replace patt subst str)

Replace the first occurrence of patt with subst in the string str. Will return the new string if patt is found, otherwise returns str.


string/replace-all

cfunction

(string/replace-all patt subst str)

Replace all instances of patt with subst in the string str. Will return the new string if patt is found, otherwise returns str.


string/reverse

cfunction

(string/reverse str)

Returns a string that is the reversed version of str.


string/slice

cfunction

(string/slice bytes [,start=0 [,end=(length str)]])

Returns a substring from a byte sequence. The substring is from index start inclusive to index end exclusive. All indexing is from 0. 'start' and 'end' can also be negative to indicate indexing from the end of the string.


string/split

cfunction

(string/split delim str)

Splits a string str with delimiter delim and returns an array of substrings. The substrings will not contain the delimiter delim. If delim is not found, the returned array will have one element.


string?

function

(string? x)

Check if x is a string.

core.janet (2336:2400)

struct

cfunction

(struct & kvs)

Create a new struct from a sequence of key value pairs. kvs is a sequence k1, v1, k2, v2, k3, v3, ... If kvs has an odd number of elements, an error will be thrown. Returns the new struct.


struct?

function

(struct? x)

Check if x a struct.

core.janet (2827:2888)

sum

function

(sum xs)

Returns the sum of xs. If xs is empty, returns 0.

core.janet (14141:14262)

symbol

cfunction

(symbol & xs)

Creates a symbol by concatenating values together. Values are converted to bytes via describe if they are not byte sequences. Returns the new symbol.


symbol?

function

(symbol? x)

Check if x is a symbol.

core.janet (2402:2466)

table

cfunction

(table & kvs)

Creates a new table from a variadic number of keys and values. kvs is a sequence k1, v1, k2, v2, k3, v3, ... If kvs has an odd number of elements, an error will be thrown. Returns the new table.


table/getproto

cfunction

(table/getproto tab)

Get the prototype table of a table. Returns nil if a table has no prototype, otherwise returns the prototype.


table/new

cfunction

(table/new capacity)

Creates a new empty table with pre-allocated memory for capacity entries. This means that if one knows the number of entries going to go in a table on creation, extra memory allocation can be avoided. Returns the new table.


table/rawget

cfunction

(table/rawget tab key)

Gets a value from a table without looking at the prototype table. If a table tab does not contain t directly, the function will return nil without checking the prototype. Returns the value in the table.


table/setproto

cfunction

(table/setproto tab proto)

Set the prototype of a table. Returns the original table tab.


table/to-struct

cfunction

(table/to-struct tab)

Convert a table to a struct. Returns a new struct. This function does not take into account prototype tables.


table?

function

(table? x)

Check if x a table.

core.janet (2767:2825)

take-until

function

(take-until pred ind)

Given a predicate, take only elements from an indexed type that satisfy the predicate, and abort on first failure. Returns a new array.

core.janet (21256:21502)

take-while

function

(take-while pred ind)

Same as (take-until (complement pred) ind).

core.janet (21505:21619)

tarray/buffer

cfunction

(tarray/buffer (array | size) )

Return typed array buffer or create a new buffer.


tarray/copy-bytes

cfunction

(tarray/copy-bytes src sindex dst dindex [count=1])

Copy count elements of src array from index sindex to dst array at position dindex memory can overlap.


tarray/length

cfunction

(tarray/length (array | buffer) )

Return typed array or buffer size.


tarray/new

cfunction

(tarray/new type size [stride = 1 [offset = 0 [tarray | buffer]]] )

Create new typed array.


tarray/properties

cfunction

(tarray/properties array )

Return typed array properties as a struct.


tarray/slice

cfunction

(tarray/slice tarr [, start=0 [, end=(size tarr)]])

Takes a slice of a typed array from start to end. The range is half open, [start, end). Indexes can also be negative, indicating indexing from the end of the end of the typed array. By default, start is 0 and end is the size of the typed array. Returns a new janet array.


tarray/swap-bytes

cfunction

(tarray/swap-bytes src sindex dst dindex [count=1])

Swap count elements between src array from index sindex and dst array at position dindex memory can overlap.


true?

function

(true? x)

Check if x is true.

core.janet (3482:3530)

try

macro

(try body catch)

Try something and catch errors. Body is any expression, and catch should be a form with the first element a tuple. This tuple should contain a binding for errors and an optional binding for the fiber wrapping the body. Returns the result of body if no error, or the result of catch if an error.

core.janet (6869:7473)

tuple

cfunction

(tuple & items)

Creates a new tuple that contains items. Returns the new tuple.


tuple/brackets

cfunction

(tuple/brackets & xs)

Creates a new bracketed tuple containing the elements xs.


tuple/slice

cfunction

(tuple/slice arrtup [,start=0 [,end=(length arrtup)]])

Take a sub sequence of an array or tuple from index start inclusive to index end exclusive. If start or end are not provided, they default to 0 and the length of arrtup respectively.Returns the new tuple.


tuple/type

cfunction

(tuple/type tup)

Checks how the tuple was constructed. Will return the keyword :brackets if the tuple was parsed with brackets, and :parens otherwise. The two types of tuples will behave the same most of the time, but will print differently and be treated differently by the compiler.


tuple?

function

(tuple? x)

Check if x is a tuple.

core.janet (2954:3015)

type

cfunction

(type x)

Returns the type of x as a keyword symbol. x is one of
    :nil
    :boolean
    :integer
    :real
    :array
    :tuple
    :table
    :struct
    :string
    :buffer
    :symbol
    :keyword
    :function
    :cfunction

or another symbol for an abstract type.


unless

macro

(unless condition & body)

Shorthand for (when (not ...

core.janet (5138:5244)

unmarshal

cfunction

(unmarshal buffer [,lookup])

Unmarshal a janet value from a buffer. An optional lookup table can be provided to allow for aliases to be resolved. Returns the value unmarshalled from the buffer.


update

function

(update ds key func & args)

Accepts a key argument and passes its' associated value to a function. The key then, is associated to the function's return value

core.janet (27474:27704)

values

function

(values x)

Get the values of an associative data structure.

core.janet (28500:28712)

varglobal

function

(varglobal name init)

Dynamically create a global var.

core.janet (1731:1867)

walk

function

(walk f form)

Iterate over the values in ast and apply f to them. Collect the results in a data structure . If ast is not a table, struct, array, or tuple, returns form.

core.janet (24890:25258)

when

macro

(when condition & body)

Evaluates the body when the condition is true. Otherwise returns nil.

core.janet (4995:5135)

when-let

macro

(when-let bindings & body)

Same as (if-let bindings (do ;body)).

core.janet (15414:15528)

with-syms

macro

(with-syms syms & body)

Evaluates body with each symbol in syms bound to a generated, unique symbol.

core.janet (8281:8555)

yield

function

(yield x)

Yield a value to a parent fiber. When a fiber yields, its execution is paused until another thread resumes it. The fiber will then resume, and the last yield call will return the value that was passed to resume.


zero?

function

(zero? x)

Check if x is zero.

core.janet (1997:2043)

zipcoll

function

(zipcoll keys vals)

Creates a table from two arrays/tuples. Returns a new table.

core.janet (27216:27471)