These forms are recoginized as special by the compiler and define the core Janet language. Most of the other functions in the core library are defined in terms of these forms, or are implemented in C for performance.
These forms are shorthands for creating top level bindings. Note that the macro forms should only be used at the top level, otherwise they will be interpreted as normal functions.
These core operators are some of the most primitive and mathematical operators, defining arithmetic and comparisons. There are also macros for C-style imperative manipulation of variables. Imperative programming should mostly be internal to functions or very simple.
Use these forms to add branching to your programming. The most primitive branching structure is the if special form.
Arrays are mutable, order sequences of values. They are one of the core data types in Janet.
Buffer represent a mutable sequence of bytes. They are much like strings but can be modified and appended to. Buffers also support other operations that treat them like generic blocks of memory.
buffer buffer/bit buffer/bit-clear buffer/bit-set buffer/bit-toggle buffer/blit buffer/clear buffer/format buffer/new buffer/new-filled buffer/popn buffer/push-byte buffer/push-string buffer/push-word buffer/slice buffer?
A predicate is a function of one argument that returns true or false. Predicates or most commonly used with combinators, like filter, keep, or find.
abstract? array? boolean? buffer? bytes? cfunction? dictionary? empty? even? every? false? fiber? function? idempotent? indexed? keyword? neg? nil? number? odd? one? pos? string? struct? symbol? table? true? tuple? zero?
Threading macros are useful for creating pipelines. The Janet threading macros are borrowed from janet. They make deeply nested code more linear form, and usually easier to read.
Strings in Janet represent both text and arbitrary byte sequences. Strings are immutable, so most operations on them will create new strings.
string string/ascii-lower string/ascii-upper string/bytes string/check-set string/find string/find-all string/format string/from-bytes string/join string/repeat string/replace string/replace-all string/reverse string/slice string/split string?
The mutable hashtable type in Janet is very versatile and can be used for an associative array, prototype based OO, and execution environments.
Structs are janet's immutable hashtable type. They are very similar to tables but do not offer prototypes, and support value equality. They make great keys for other structs or tables.
Tuples are immutable lists. They are also the data type used to represent function calls, macro invocations, and special forms in Janet. They come in two flavors, bracketed and unbracketed tuples.
Fibers represent a separate flow of execution in Janet, with it's own stack an execution context. Multiple fiber's can be run on the same OS thread, in this sense they are more fine grained than OS threads.
Typed arrays are wrappers around C style arrays of integers, and are useful for interfacing with C libraries that contain such structures in a uniform way.
Pegs, or Parsing Expression Grammars, are Janet's main pattern matching facility, replacing regular expressions in other languages.
Janet offers several functions for operating with the OS in both platform dependent and platform independent ways.
Janet offers basic file I/O for interacting with the file system. The file library is mostly a wrapper around the C stdio library.
Interact with the Janet module system. Janet has a simple but not inflexible system for mapping module names to file paths, preventing modules from loading more than once, and import and exporting symbols from one module to another.
Inspect or create functions from Janet bytecode
These functions and macros are useful for writing your own macros. Also checkout the quasiquote special form.
Besides the primitive while loop and tail recursion, Janet has a handful of macros for looping.
Combinators are what make up the bread and butter of the Janet core library. Combinators perform transformations on data structures or functions, resulting in code that is usually more succinct than imperative code. Use liberally.
all comp complement count distinct drop-until drop-while every? extreme filter find find-index first flatten flatten-into frequencies identity interleave interpose invert juxt juxt* keep keys kvs last map mapcat max max-order merge min min-order pairs partial partition postwalk prewalk product range reduce reverse some sort sorted sum take-until take-while update values walk zipcoll
Grab bag of other forms in the core library.