jf Documentation

Here are several examples of Jeff expressions and their results, along with some complete scripts and commands you can run on ANSI-compatible unix-like terminals.

Jeff/jf (Json Formulas) is just a command-line app which lets you view, transform, and convert data from/to common data formats, like JSON, JSONL, CSV, TSV, SSV, HTML, plain text, and many others. Input and output are JSON by default, unless overridden by named file/URI inputs, or via options -from and -to. Jeff even has special line-by-line input modes both for plain-text (called each-line) and for JSONL data (called each-value), enabling stream-processing.

Jeff also lets you run a command to transform data, run using a surprisingly capable scripting engine. If the command is a dot, it means keep input data as they are. Scripts give you all sorts of conveniences you may have come to expect from other popular tools, such as negative indexing, but that's barely scratching the surface: Jeff gives you many other handy features, such as automatic depth-first recursion for most operators and functions.

Scripts can use 200+ predefined funcs, not counting aliases; plenty of global variables with all sorts of data are also available. Some of these predefined functions/values are documented on this help page. Many names/aliases should be familiar if you know JavaScript, Go, or Python: just avoid package names, avoid underscores, keep all letters lowercase, and chances are you'll get the right Jeff names.

As frequently shown here, the most convenient way to call 1-input funcs on non-objects is to use them as fake-properties of their input. Since objects have real properties, you have to use parentheses to call funcs explicitly on them, as many examples show.

Jeff can even output documents via special comments in HTML and SVG files, when they're used via the template option, while still being able to (optionally) load inputs files. The results of all template expressions are always automatically escaped. You still want to ensure any URIs you emit are valid, as their escaping is safe but useless as (non-working) links.

Types

Here are all types functions support: values of types bigint, fraction, and skip aren't compatible with JSON.

null null value
boolean true or false
number 64-bit floating-point number, with NaN, +inf, and -inf
string plain-text encoded as UTF-8
array arbitrary-length list of values; also called `list`
object ordered associative array with string keys
bigint arbitrary-sized integer number, to calculate enormous quantities
fraction rational number, whose numerator and denominator are bigints
skip ignore-me value which affects loops, arrays, and objects

Input/Output Formats

Json Convert (jc) is a tool which can convert several formats into JSON, especially those Jeff doesn't know how to load, such as YAML. Just cmd-line pipe jc in front of jf, and you're good to go.

Here are values options -from and -to accept: the default input type is `json`, unless filenames or webserver responses suggest otherwise; the default output is also `json`.

All IO types, except `envars`, and `live`, have a counterpart ending in `.gz` or `.gzip` (i.e. jsonl.gz), indicating it's GZIP encodied. All input types also have BZIPped counterparts, their names ending in `.bz`, `.bzip`, or `.bzip2`. Even IO aliases have such counterparts.

format in out alias description
ansi a text styled with ANSI codes
bytes b generic data bytes, without structure
env lines of key-value pairs, the latter separated by an `=`
html h when used as output, page is self-contained
json j JSON, allowing comments and trailing commas in input
jsonl jl JSON Lines, allowing comments and trailing commas in input
lines l lines of text as an array
msgpack mp message pack, a binary JSON-like data format
text t UTF-8 text, without structure
tsv tab-separated values, representing a table
blocks bl empty-line separated blocks/arrays of lines
csv comma-separated values, representing a table
each-line el line-by-line / streaming mode: scripts are run repeatedly
each-value ev line-by-line / JSON-line streaming mode: scripts are run repeatedly
envars use environment variables as input
ini configuration values; subset of TOML format
log NCSA common log format
null n don't read any input
ssv space-separated values, representing a table
strict-json sj proper JSON: no comments, no trailing commas
strict-jsonl sjl proper JSONL: no comments, no trailing commas
unif-conf uc key-value pairs; empty-ish lines and lines starting with `#` are ignored
unix-list ul array of strings; empty-ish lines and lines starting with `#` are ignored
xml x still used by governments and other big organizations
docs this very documentation in HTML format; aliases are doc, and help
gron same text format emitted by gron, a tool to make JSON `greppable`
json0 j0 compact JSON; 1-line output avoiding unnecessary spaces
json1 j1 JSON with 1-space indentation
json2 j2 JSON with 2-spaces indentation
json4 j4 JSON with 4-spaces indentation
json-tab jt JSON with tab indentation
live gui interactive-use mode via web browser, restricted to localhost
rec grep/sed/awk-friendly plain-text RECords
geojson GEOgraphic JSON, alias for `json`
ipynb Interactive PYthon NoteBook, alias for `json`
json5 JSON-like format with a looser syntax, alias for `json`
jsonc JSON with Commas, alias for `json`
rss r feeds, usually for podcasts, alias for `xml`

Examples of Various Syntax

var = formula assignment
x = 30 30
x := "hi" "hi"
value . func (args...) fake-method function call
`abc`.upper() "ABC"
10.log10() 1
10.sqrt().log10() 0.5
1..3.sqrt().tofixed(3) ["1.000", "1.414", "1.732"]
nonobject . function fake-property function call
`abc`.upper "ABC"
10.log10 1
10.sqrt.log10 0.5
1..3.sqrt.fix3 ["1.000", "1.414", "1.732"]
object . property JS-like object-property access
monthlen . January 31
value ?? value denull syntax
null ?? `ok` "ok"
nan ?? `ok` NaN
[:] exclusive slice syntax
"abc😁def"[2:5] "c😁d"
"a😁bc"[:1..3] ["a", "a😁", "a😁b"]
monthlen[`February`:`March`] {"February": 28}
monthlen[:`March`] {"January": 31, "February": 28}
[..] inclusive slice syntax
"abc😁def"[2..5] "c😁de"
"a😁bc"[:1..3] ["a😁", "a😁b", "a😁bc"]
monthlen[`February`..`March`] {"February": 28, "March": 31}
monthlen[..`March`] {"January": 31, "February": 28, "March": 31}
value .? value safe property access
null .? abc .? def null
[v: src] array by formula
[v**2: 4] [1, 4, 9, 16]
[v.lower: "ABC"] ["a", "b", "c"]
[v**2: [1, 4, 3]] [1, 16, 9]
[x => x**2: [1, 4, 3]] [1, 16, 9]
[k + v: [1, 4, 3]] [1, 5, 5]
[(i, x) => i + x: [1, 4, 3]] [1, 5, 5]
[(s, x) => (s, x): {"a": 4, "b": null}] [["a", 4], ["b": null]]
[(s, x) => x: {"a": 4, "b": null}] [4, null]
[k+v: {"a": 4, "b": null}] ["a4", "bnull"]
[[7, null]: 3] [[7, null], [7, null], [7, null]]
{k: v: src} dictionary by formulas
{`sqrt(${v})`: v.sqrt.fix4: 3} {"sqrt(1)": "1.0000", "sqrt(2)": "1.4142", "sqrt(3)": "1.7321"}
{k: v: 1..3} {"0": 1, "1": 2, "2": 3}
{v: k: 1..3} {"1": 0, "2": 1, "3": 2}
{v: k: 3} {"1": 0, "2": 1, "3": 2}
{(i, x) => i: v: 1..3} {"0": 1, "1": 2, "2": 3}
{v: (i, x) => i: 1..3} {"1": "0", "2": "1", "3": "2"}
{v: k: {"a": 4, "b": null}} {"4": "a", "null": "b"}
value @ func revalue syntax
monthlen[:3]@sign {"January": 1, "February": 1, "March": 1}
value .@ func try-revalue syntax
monthlen[:3].@sign {"January": 1, "February": 1, "March": 1}
{bindings} => expr local values/vars
{e: `ln`, nan: `not a nan`} => nan "not a nan"
cond ? yes : no ternary if-else operator
true ? {} : `not happening` {}
2 >= 3 ? `What?` : `of course not` "of course not"

Examples of Unary Operators

! boolean negation
!false true
!true false
!0 true
!-1.5 false
!nan false
+ convert to number
+false 0
+true 1
+123.456 123.456
+nan NaN
+"abc" NaN
+"123.456" 123.456
+-304n -304
+(5n / 2n) 2.5
- negate number(s)
-(-1.5) 1.5
-nan NaN
-(1, 2, 3) [-1, -2, -3]
-{a: 1, b: 2} {"a": -1, "b": -2}
-(-304n) 304
-(5n / 2n) -5 / 2
... splat
[5, 3.iota..., "abc"] [5, 1, 2, 3, "abc"]
[5, [1, 4]..., [1, 3]] [5, 1, 4, [1, 3]]
{{a, b}..., "end": 1} {"a": "a", "b": "b", "end": 1}
[{a, b}..., "text"] ["a", "b", "text"]
replace( ["excel", "e", ""]...) "xcl"

Examples of Binary Operators

+ addition, or string concatenation
3 + 4.5 7.5
4.5 + "abc" "4.5abc"
"abc" + 4.5 "abc4.5"
"some" + "text" "sometext"
3 + (4.5, "abc") [7.5, "3abc"]
(4.5, "abc") + 3 [7.5, "abc3"]
3 + {a: 4.5, b: "abc"} {"a": 7.5, "b": "3abc"}
{a: 4.5, b: "abc"} + 100 {"a": 104.5, "b": "abc100"}
3n + 4.2n 36 / 5
- subtraction, or substring removal
3 - 4.5 -1.5
"sassy" - "ss" "say"
"something" - "methi" "song"
"excellent" - "e" "xcllnt"
3 - (4.5, 1) [-1.5, 1]
3 - {a: 4.5, b: 1} {"a": -1.5, "b": 2}
3n - 4.2n -6 / 5
* multiplication, or string repetition
3 * 4.5 13.5
3.9 * "-" "---"
"abc" * 3.9 "abcabcabc"
3 * (4.5, 1) [13.5, 3]
{a: 4.5, b: 1} * 3 {"a": 13.5, "b": 3}
3 * {a: 4.5, b: 1} {"a": 13.5, "b": 3}
{a: 4.5, b: 1} * 3 {"a": 13.5, "b": 3}
3n * 0.5n 3 / 2
/ division, or string splitting
4.5 / 3 1.5
"abcdef" / 3 ["ab", "cd", "ef"]
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„" / 2 ["πŸ˜€πŸ˜πŸ˜‚", "πŸ˜ƒπŸ˜„"]
"abc,def,xyz" / "," ["abc", "def", "xyz"]
"," / "abc,def,xyz" [","]
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„" / "" ["πŸ˜€", "😁", "πŸ˜‚", "πŸ˜ƒ", "πŸ˜„"]
3 / (4.5, 1) [0.6666666666666666, 3]
(4.5, 1) / 3 [1.5, 0.3333333333333333]
3 / {a: 4.5, b: 1} {"a": 0.6666666666666666, "b": 3}
{a: 4.5, b: 1} / 3 {"a": 1.5, "b": 0.3333333333333333}
2n / 3n 2 / 3
** powers
3.4 ** 2.32 17.10137725277502
5.2n ** 13n 2,481,152,873,203,736,576 / 1,220,703,125
4.2n ** -3n 125 / 9,261
.. number sequencing
-3..-3 [-3]
3..6.2 [3, 4, 5, 6]
3.25..-2.2 [3.25, 2.25, 1.25, 0.25, -0.75, -1.75]
^ number sequencing, array joining, or object flattening
-3 ^ -3 [-3]
3 ^ 6.2 [3, 4, 5, 6]
3.25 ^ -2.2 [3.25, 2.25, 1.25, 0.25, -0.75, -1.75]
("a", "b", "c") ^ "" "abc"
"" ^ ("a", "b", "c") "abc"
"; " ^ ("a", "b", -7, "c") "a; b; -7; c"
("a", "b", "c") ^ (1, 2, 3) {"a": 1, "b": 2, "c": 3}
(-20, 12.75, "hey, hi!") ^ (1, 2) {"-20": 1, "12.75": 2, "hey, hi!": null}
{"a": {"b": 1, "c": 2}, "d": 3} ^ "/" {"a/b": 1, "a/c": 2, "d": 3}
&& boolean and
true && false false
|| boolean or
true || false true
| pipes
x = 4 | x 4
2**4 | _.sqrt | _ + 3 7
; pipes
x = 4; x 4
2**4 ; _.sqrt ; _ + 3 7
mixing operators
"a b c" / " " ^ "," "a,b,c"
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„" / 3 ^ "\n" "πŸ˜€πŸ˜\nπŸ˜‚πŸ˜ƒ\nπŸ˜„"

Examples of Other Operators

[index/slice] 0-based indexing
"abc"[1] "b"
"abc"[-1] "c"
[1, 2, 3][1] 2
[1, 2, 3][-1] 3
{a: 1, b: 2, c: 3}[2] 3
{a: 1, b: 2, c: 3}[-1] 3
{a: 1, b: 2, c: 3}["a"] 1
{a: 1, b: 2, c: 3}["d"] null
: 0-based exclusive slicing
[1, 2, 3][:2] [1, 2]
[1, 2, 3][0:2] [1, 2]
[1, 2, 3][:] [1, 2, 3]
{a: 1, b: 2, c: 3}[:] [1, 2, 3]
{a: 1, b: 2, c: 3}[:2] {"a": 1, "b": 2}
{a: 1, b: 2, c: 3}[:-1] {"a": 1, "b": 2}
{a: 1, b: 2, c: 3}[:-2] {"a": 1}
{a: 1, b: 2, c: 3}[:"b"] {"a": 1}
{a: 1, b: 2, c: 3}[:"c"] {"a": 1, "b": 2}
.. 0-based inclusive slicing
[1, 2, 3][..2] [1, 2, 3]
[1, 2, 3][0..2] [1, 2, 3]
[1, 2, 3][..] [1, 2, 3]
{a: 1, b: 2, c: 3}[..] {a: 1, b: 2, c: 3}
{a: 1, b: 2, c: 3}[..2] {"a": 1, "b": 2, "c": 3}
{a: 1, b: 2, c: 3}[..-1] {"a": 1, "b": 2, "c": 3}
{a: 1, b: 2, c: 3}[..-2] {"a": 1, "b": 2}
{a: 1, b: 2, c: 3}[.."b"] {"a": 1, "b": 2}
{a: 1, b: 2, c: 3}[.."c"] {"a": 1, "b": 2, "c": 3}
.. sequencing
3..5 [3, 4, 5]
4.25 .. 0.9 [4.25, 3.25, 2.25, 1.25]
... splat
[1, [2, 3], [4, 5, 6]..., 7] [1, [2, 3], 4, 5, 6, 7]
{a: 1, b: 2, c: 3}... [1, 2, 3]

Examples of Normal Functions

abs absolute value
false.abs 0
true.abs 1
(-4.234).abs 4.234
(-123n).abs 123
(-123.4n).abs 617 / 5
acos arc cosine, inverse cosine
acosh hyperbolic arc cosine
array make an array/list of values
array() []
array(null, -3, "hi") [null, -3, "hi"]
array(-3.2, ["abc", null]) [-3.2, ["abc", null]]
array(-3.2, ["abc", null], {a: 34, b: nan}) [-3.2, ["abc", null], {"a": 34, "b": nan}]
array(4, 5, 6, 7, 8) [4, 5, 6, 7, 8]
asin arc sine, inverse sine
asinh hyperbolic arc sine
assign, update update/override object key-value pairs
{a: 2, b: 3}.assign({a: 1, c: 9}) {"a": 1, "b": 3, "c": 9}
{a: 2, b: 3}.assign({a: 1, c: 9}, {c: null}) {"a": 1, "b": 3, "c": null}
atan arc tangent, inverse tangent
atanh hyperbolic arc tangent
balls make a string of n ball/circle symbols
-1.5.balls ""
0.balls ""
4.balls "●●●●"
4.99.balls "●●●●"
basename get filename without preceding folders
"folder/file.txt".basename "file.txt"
base64 turn array of byte-like numbers into a base64 string
(1, 2, 3).base64 "AQID"
beta beta function
beta(1, 2) 0.5
bigint make a bigint
-3.bigint -3
-3.3.bigint -3
(-304n).bigint -304
bin convert number into string of binary digits
333.bin "101001101"
bool, boolean make a boolean
null.bool false
false.bool false
0.bool false
"".bool false
().bool false
{}.bool false
0n.bool false
true.bool true
(-3).bool true
123.456.bool true
nan.bool true
"abc".bool true
[false].bool true
{a: false}.bool true
(-304n).bool true
0.5n.bool true
break break a container into n parts, or fewer
"abcdefghi".break(2) ["abcde", "fghi"]
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„".break(2) ["πŸ˜€πŸ˜πŸ˜‚", "πŸ˜ƒπŸ˜„"]
(1, 2, 3, 4, 5).break(3) [[1, 2], [3, 4], [5]]
monthlen.break(2) [ {"January": 31, "February": 28, "March": 31, "April": 30, "May": 31, "June": 30}, {"July": 31, "August": 31, "September": 30, "October": 31, "November": 30, "December": 31} ]
bullets make a string of n bullet symbols
-1.5.bullets ""
0.bullets ""
4.bullets "β€’β€’β€’β€’"
4.99.bullets "β€’β€’β€’β€’"
cbrt cube root
27.cbrt 3
cc, currencycode get the 3-letter currency code for a country
"ca".cc "CAD"
"canada".cc "CAD"
"United States of America".cc "USD"
"United States".cc "USD"
"MX".cc "MXN"
"FRA".cc "EUR"
ceil, ceiling round numbers up
3.3.ceil 4
century round down by 100s
1995.century 1,900
chars, runes split a string into an array of 1-item strings
"".chars []
"abcdef".chars ["a", "b", "c", "d", "e", "f"]
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„".chars ["πŸ˜€", "😁", "πŸ˜‚", "πŸ˜ƒ", "πŸ˜„"]
"πŸ˜€πŸ˜\nπŸ˜‚\nπŸ˜ƒπŸ˜„".chars ["πŸ˜€", "😁", "\n", "πŸ˜‚", "\n", "πŸ˜ƒ", "πŸ˜„"]
chr
65.chr "A"
chunk break a container into parts, each up to the length given
"abcdef".chunk(3.8) ["abc", "def"]
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„".chunk(2) ["πŸ˜€πŸ˜", "πŸ˜‚πŸ˜ƒ", "πŸ˜„"]
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„".chunk(3) ["πŸ˜€πŸ˜πŸ˜‚", "πŸ˜ƒπŸ˜„"]
(1, 2, 3, 4, 5, 6, 7, 8).chunk(2) [[1, 2] [3, 4], [5, 6], [7, 8]]
(1, 2, 3, 4, 5, 6, 7, 8).chunk(3) [[1, 2, 3], [4, 5, 6], [7, 8]]
monthlen.chunk(3) [ {"January": 31, "February": 28, "March": 31}, {"April": 30, "May": 31, "June": 30}, {"July": 31, "August": 31, "September": 30}, {"October": 31, "November": 30, "December": 31} ]
circles make a string of n circle symbols
-1.5.circles ""
0.circles ""
4.circles "●●●●"
4.99.circles "●●●●"
concat, concatenate concatenate into a string
contains does a string contain the substring given?
"abc # 123".contains("# ") true
continent get the continent for a country name/identifier
"ca".continent "North America"
"canada".continent "North America"
"United States of America".continent "North America"
"United States".continent "North America"
"MX".continent "North America"
"FRA".continent "Europe"
cos cosine
(pi / 2).cos 0
cosh hyperbolic cosine
(pi / 2).cosh 2.5091784786580567
count count occurrences in a string or container
country get the common name for a country name/identifier
"ca".country "Canada"
"canada".country "Canada"
"United States of America".country "United States"
"United States".country "United States"
"MX".country "Mexico"
"MEX".country "Mexico"
crosses make a string of n cross symbols
-1.5.crosses ""
0.crosses ""
4.crosses "Γ—Γ—Γ—Γ—"
4.99.crosses "Γ—Γ—Γ—Γ—"
dashes make a string of n dash symbols
-1.5.dashes ""
0.dashes ""
4.dashes "––––"
4.99.dashes "––––"
datauri turn byte-like arrays into base64 data-URI strings
[1, 2, 3].base64 AQID
debase64 turn a base64 string into an array of byte-like numbers
"AQID".debase64 [1, 2, 3]
decade round down by 10s
1995.decade 1,990
dedup, set, unique ignore repeating array items
(3, 2, "3", 1, 3, "hi!").dedup [3, 2, "3", 1, "hi!"]
default fill-in missing items in an object
{a: 4.5, b: "abc"}.default({c: null}) {"a": 4.5, "b": "abc", "c": null}
{a: 4.5, b: "abc"}.default({a: null}) {"a": 4.5, "b": "abc"}
deg, degrees turn radians into angular degrees
(pi / 4).degrees 45
pi.degrees 180
dehtml, unhtml unescape/decode HTML symbol-aliases
"Tom & Jerry".dehtml "Tom & Jerry"
deinf replace either number infinity with any alternative
null.deinf(0) null
false.deinf(null) false
0.deinf(null) 0
(-inf).deinf(null) null
inf.deinf(null) null
"".deinf(null) ""
().deinf(null) []
{}.deinf(null) {}
123n.deinf(null) 123
del, delete, drop remove keys from object
{a: 123, b: 456}.del("a") {"b": 456}
{a: 123, b: 456}.del("a", "b", "c") {}
denom, denominator get the denominator as a bigint
123n.denom 1
(-2n / 3n).denom 3
dirname get directory/folder name
"folder/file.txt".dirname "folder"
dumps, json, stringify turn any supported value into a JSON string
(1, 2, "abc").json "[1, 2, \"abc\"]"
dup
null.dup(5) [null, null, null, null, null]
false.dup(5) [false, false, false, false, false]
4.dup(10) [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]
("~").dup(5) ["~", "~", "~", "~", "~"]
().dup(10) []
[4].dup(10) [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]
(1, 2).dup(4) [1, 2, 1, 2, 1, 2, 1, 2]
(1, 2).dup(-43) []
3n.dup(5) [3n, 3n, 3n, 3n, 3n]
2.3n.dup(5) [23 / 10, 23 / 10, 23 / 10, 23 / 10, 23 / 10]
endswith, hassuffix check if a string ends as indicated
"line\r".endswith("\r") true
"line".endswith("\r") false
equalfold are 2 strings equal when ignoring unicode-casing?
"TeXt".equalfold("text") true
erf error function
erfc complementary error function
err, error, fail raise an error using the string given
exp exponential function
0.exp 1
1.exp 2.718281828459045
ext get the file extension from a path
"folder/file.txt".ext ".txt"
exp2, pow2 2**x
2.pow2 8
exp10, pow10 10**x
3.pow10 1,000
expm1 e**x - 1, more accurately
1.expm1 1.7182818284590451
fields, words trim a string, then split it on runs of 1 or more spaces
"  abc  123 xy ".fields ["abc", "123", "xy"]
" 123 abc   def".fields ["123", "abc", "def"]
first, limit get the first n items, or restrict container to its leading items
"abcdef".first "a"
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„".first "πŸ˜€"
("hi", 2, 3, 550, -2).first "hi"
{a: 123, b: "hi!"}.first() 123
{a: null, b: "hi!"}.first(1) {"a": null}
"abcdef".first(5) "abcde"
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„".first(2) "πŸ˜€πŸ˜"
("hi", 2, 3, 550, -2).first(4) ["hi", 2, 3, 550]
("hi", 2, 3, 550, -2).first(-4) []
{a: null, b: "hi!"}.first(30) {"a": null, "b": "hi!"}
first1, ..., first9 get the first n items, or restrict container to its leading items
fix, fixed, tofixed turn number into a string rounded to n decimals
123_456.7890123.fix(4) "123456.7890"
fix0, ..., fix9 turn number into a string rounded to n decimals
123_456.7890123.fix0 "123457"
123_456.7890123.fix1 "123456.8"
123_456.7890123.fix2 "123456.79"
123_456.7890123.fix3 "123456.789"
123_456.7890123.fix4 "123456.7890"
123_456.7890123.fix5 "123456.78901"
123_456.7890123.fix6 "123456.789012"
fixed0, ..., fixed9 aliases for fix0, ..., fix9
tofixed0, ..., tofixed9 aliases for fix0, ..., fix9
flag get the emoji-flag for a country name/identifier
"ca".flag "πŸ‡¨πŸ‡¦"
"canada".flag "πŸ‡¨πŸ‡¦"
"United States of America".flag "πŸ‡ΊπŸ‡Έ"
"United States".flag "πŸ‡ΊπŸ‡Έ"
"MX".flag "πŸ‡²πŸ‡½"
"MEX".flag "πŸ‡²πŸ‡½"
flat, flatten, flattened turn array into a shallow one
(3, (4, 5), ("abc")).flat [3, 4, 5, "abc"]
float, n, number turn value into a (float64) number
false.n 0
true.n 1
123.456.n 123.456
nan.n NaN
"abc".n NaN
"123.456".n 123.456
(-304n).n -304
(5n / 2n).n 2.5
floor round numbers down
folds, foldstr, foldstring wrap string into lines using the (optional) max width given
gamma gamma function
pi.gamma 2.288037795340032
1.gamma 1
2.gamma 1
3.gamma 2
4.gamma 6
5.gamma 24
getattr get attribute, or null, or the fallback value given
{"a": 123}.getattr("abc") null
{"a": 123}.getattr("abc", nan) NaN
hasattr, hasattrs, haskey, haskeys check if object has all the keys given, or any keys
{}.hasattrs() false
{a: 123}.hasattrs() true
{a: 123}.hasattrs("abc") false
{a: 123, b: null}.hasattrs("a", "b") true
hasprefix, startswith check if a string starts as indicated
"# comment".hasprefix("# ") true
"abc # 123".hasprefix("# ") false
hex convert number into string of hexadecimal digits
333.hex "14d"
hms2s parse time-duration strings into seconds
"1:23:45:56.23".hms2s 171,956.23
holes make a string of n hollow-circle/hole symbols
-1.5.holes ""
0.holes ""
4.holes "β—‹β—‹β—‹β—‹"
4.99.holes "β—‹β—‹β—‹β—‹"
hypot multi-dimensional hypothenuse
hypot(3, 4) 5
hypot(3, 4, 52.8) 53.03621404285943
in is a value in a container?
indexes, indices make an array with numbers 0 .. n-1
-3.1.indices []
0.9.indices []
3.99.indices [0, 1, 2]
(inf, nan).indices [0, 1]
{a: 4.5, b: 1}.indices() [0, 1]
iota make an array with numbers 1 .. n
-3.1.iota []
0.9.iota []
3.99.iota [1, 2, 3]
(inf, nan).iota [1, 2]
{a: inf, b: nan}.iota [1, 2]
isfin, isfinite check value is neither infinity
isinf check for either infinity
null.isinf false
false.isinf false
nan.isinf false
"abc".isinf false
(inf, nan).isinf false
{a: inf, b: nan}.isinf false
100n.isinf false
inf.isinf true
(-inf).isinf true
isnan check for NaN
null.isnan false
false.isnan false
inf.isnan false
(-inf).isnan false
"abc".isnan false
(inf, nan).isnan false
{a: inf, b: nan}.isnan false
100n.isnan false
nan.isnan true
iso2 get the ISO 2-letter code for a country name/identifier
"ca".iso2 "CA"
"canada".iso2 "CA"
"United States".iso2 "US"
"United States of America".iso2 "US"
"MX".iso2 "MX"
"MEX".iso2 "MX"
iso3 get the ISO 3-letter code for a country name/identifier
"ca".iso3 "CAN"
"canada".iso3 "CAN"
"United States".iso3 "USA"
"United States of America".iso3 "USA"
"MX".iso3 "MEX"
"MEX".iso3 "MEX"
join join array items using a separator string
("a", "b", "c", 1, 2, 3).join "abc123"
("a", "b", "c").join("") "abc"
"".join(("a", "b", "c")) "abc"
"; ".join(("a", "b", -7, "c")) "a; b; -7; c"
j0 0th-order bessel j function
j1 1st-order bessel j function
jn(n, x) nth-order bessel j function
last get the last n items
"abcdef".last "f"
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„".last "πŸ˜„"
("hi", 2, 3, 550, -2).last -2
{a: null, b: "hi!"}.last() "hi!"
{a: null, b: "hi!"}.last(1) {"b": "hi!"}
"abcdef".last(5) "bcdef"
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„".last(2) "πŸ˜ƒπŸ˜„"
("hi", 2, 3, 550, -2).last(4) [2, 3, 550, -2]
("hi", 2, 3, 550, -2).last(-4) []
{a: null, b: "hi!"}.last(30) {"a": null, "b": "hi!"}
last1, ..., last9 get the last n items
lbeta log-beta function
lbeta(1, 2) -0.6931471805599453
len, length count number of items
"abcdef".len 6
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„".len 5
(1, 2, 3, 550, -2).len 5
{a: null, b: "hi!"}.len 2
lgamma log-gamma function
ln, log natural logarithm
1.ln 0
e.ln 1
e.log 1
loads, parse, parsejson parse a JSON string
"{\"a\": 1, \"b\": 2}".parse {"a": 1, "b": 2}
log(base, x) logarithm in the base given
log(2, 8) 3
log1p ln(1 + x), to calculate interest more accurately
0.05.log1p 0.0487901641694320
log2 logarithm in base 2
1_024.log2 10
log10 logarithm in base 10
1_000_000.log10 6
logistic logistic function
(-inf).logistic 0
0.logistic 0.5
inf.logistic 1
lower, tolower, tolowercase unicode-lowercase string
"AbCdE".lower "abcde"
"NO SHOUTING, PLEASE!".lower "no shouting, please!"
lstrip, ltrim remove leading whitespace in a string
"    abc".lstrip "abc"
match, matches match strings to RE2-style regular expressions
" xyyyz".matches("xy*z") true
" xyyyz".matches("^xy*z") false
max maximum function, accepts any # of args
max(-3.4) -3.4
max(-3.4, -1_000) -3.4
max(-3.4, -34, 49.4) 49.4
min minimum function, accepts any # of args
min(-3.4, -3453, 49.4, 30) -3453
mod modulus function
3.5.mod(2) 1.5
name2mime guess MIME type from a filepath
"folder/file.mp3".name2mime "audio/mpeg"
"folder/file.mp4".name2mime "video/mp4"
"folder/file.JPG".name2mime "image/jpeg"
neg, negate negate number(s)
(-1.5).neg 1.5
nan.neg NaN
(1, 2, 3).neg [-1, -2, -3]
{a: 1, b: 2}.neg() {"a": -1, "b": -2}
(-304n).neg 304
(5n / 2n).neg -5 / 2
not negate boolean
false.not true
true.not false
0.not false
-3.542.not false
nan.not false
numer, numerator get the numerator as a bigint
123n.numer 123
(-2n / 3n).numer -2
pow, power x**y, the power function
2.5.pow(-1.5) 0.2529822128134703
3.pow((4.5, 1)) [140.29611541307906, 3]
(4.5, 1).pow(3) [91.125, 1]
3.pow({a: 4.5, b: 1}) {"a": 140.29611541307906, "b": 3}
{a: 4.5, b: 1}.pow(3) {"a": 91.125, "b": 3}
4.2n.pow(-3n) 125 / 9,261
r0, .., r9, round0, .., round9 round number to n decimal digits
123_456.7890123.r0 123,457
123_456.7890123.r1 123,456.8
123_456.7890123.r2 123,456.79000000001
123_456.7890123.r3 123,456.78900000000
123_456.7890123.r4 123,456.78900000000
123_456.7890123.r5 123,456.78901000001
123_456.7890123.r6 123,456.78901199999
rad, radians turn angular degrees into radians
90.rad 1.570796326794897
rep, repeat
"~".rep(-40) ""
"~".rep(5) "~~~~~"
"~".rep(5, "-") "~-~-~-~-~"
replace, replaceall substitute all substring occurrences
"a b c".replace(" ") "abc"
reverse, reversed reverse items
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„".reverse "πŸ˜„πŸ˜ƒπŸ˜‚πŸ˜πŸ˜€"
(1, 2, 3).reverse [3, 2, 1]
{a: 1, b: 2}.reverse() {b: 2, a: 1}
skip skip up to n leading items
"".rest ""
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„".rest "πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„"
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„".skip(2) "πŸ˜‚πŸ˜ƒπŸ˜„"
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„".skip(20) ""
("abc", false, null).rest [false, null]
("abc", false, null).skip(3) []
{abc: -123, def: null}.rest() {def: null}
{abc: -123, def: null}.skip(20) {}
squares, tiles make a string of n squares/tiles
-1.5.tiles ""
0.tiles ""
4.tiles "β– β– β– β– "
4.99.tiles "β– β– β– β– "
round round numbers
21.3.round 21
21.8.round 22
round round to the number of decimals given
21.25.round(0) 21
21.25.round(1) 21.3
21.25.round(2) 21.25
rstrip, rtrim remove trailing whitespace in a string
"123 e \r".rstrip "123 e"
second get the 2nd item in a container
"abcdef".second "b"
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„".second "😁"
("hi", 2, 3, 550, -2).second 2
{a: 123, b: "hi!"}.second() "hi!"
sin sine
pi.sin 0
(pi / 2).sin 1
sinh hyperbolic sine
(pi / 2).sinh 2.301298902307295
spaces make a string of n spaces
-1.5.spaces ""
0.spaces ""
4.spaces "    "
4.99.spaces "    "
split split a string on the separator given
"abc,def,xyz".split(",") ["abc", "def", "xyz"]
"abcdef".split("") ["a", "b", "c", "d", "e", "f"]
"πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„".split("") ["πŸ˜€", "😁", "πŸ˜‚", "πŸ˜ƒ", "πŸ˜„"]
sqrt square root
2.sqrt 1.4142135623730951
squares make a string of n square symbols
-1.5.squares ""
0.squares ""
4.squares "β– β– β– β– "
4.99.squares "β– β– β– β– "
squeeze, squeezed trim surrounding whitespace and squeeze multiple spaces
" 123    e\r\n".squeeze "123 e"
s, str, string, tostring turn a value into a string
null.str "null"
true.str "true"
-3.75.str "-3.75"
"abc".str "abc"
(123, "abc").str "[123,"abc"]
{"a": 1, "b": true}.str() "{a:1,b:true}"
304n.str "304"
0.75n.str "3 / 4"
strings detect all ASCII strings in a byte-like array
strip, stripped, trim remove surrounding whitespace
" 123    e\r\n".strip "123    e"
s2hms turn seconds into a time-duration string
171_956.23.s2hms "1:23:45:56.23"
tan tangent
(pi / 4).tan 1
tanh hyperbolic tangent
(pi / 4).tanh 0.6557942026326724
textafter remove all text up to the end of the substring given
"abcdef".textafter("bc") "def"
"abcdef".textafter("xyz") ""
textbefore remove all text starting from the substring given
"abcdef".textbefore("bc") "a"
"abcdef".textbefore("xyz") "abcdef"
title, titled turn string into a title-cased one
"breakfast in america".titled "Breakfast In America"
"NO SHOUTING, PLEASE!".title "No Shouting, Please!"
tofixed turn number into a string rounded to n decimals
123_456.7890123.tofixed(0) "123457"
123_456.7890123.tofixed(1) "123456.8"
123_456.7890123.tofixed(2) "123456.79"
123_456.7890123.tofixed(3) "123456.789"
toupper, touppercase, upper unicode-uppercase string
"AbCdE".upper "ABCDE"
"No shouting, please!".upper "NO SHOUTING, PLEASE!"
tr, transpose, transposed switch nesting of values
({a: 123, b: 456}, {a: 789, b: null}).tr {"a": [123, 789], "b": [456, null]}
trim, trimmed, trimspace remove surrounding whitespace
" 123    e\r\n".trim "123    e"
trimbefore remove all text up to the end of the substring given
"abcdef".trimbefore("bc") "a"
"abcdef".trimbefore("xyz") "abcdef"
trimdec, trimdecs, trimdecimals remove excessive trailing zeros after a dot
"123,456,000".trimdec 123,456,000
"123,456.0000".trimdec 123,456
"123,456.789000".trimdec 123,456.789
trimend remove trailing whitespace in a string
"123 e \r".trimend "123 e"
textbefore remove all text starting from the substring given
"abcdef".textbefore("bc") "a"
"abcdef".textbefore("xyz") "abcdef"
trimprefix remove starting substring, if present
"# comment".trimprefix("# ") "comment"
"abc # 123".trimprefix("# ") "abc # 123"
trimstart remove leading whitespace in a string
"    abc".trimstart "abc"
trimsuffix remove ending substring, if present
"text line\r".trimsuffix("\r") "text line"
"text line".trimsuffix("\r") "text line"
trunc, truncate truncate, or round closer to 0
-19.9.trunc -19
19.9.trunc 19
tryn, trynumber convert value into a number, or keep value on failure
null.tryn null
false.tryn 0
33.tryn 33
"33".tryn 33
"abc".tryn "abc"
[4].tryn [4]
[null].tryn [null]
{a: null}.tryn() {"a": null}
tstype get any value's TypeScript type
null.tstype "null"
false.tstype "boolean"
3.5.tstype "number"
"".tstype "string"
().tstype "any[]"
(1, 2, 3).tstype "number[]"
(-5.3, "abc").tstype "(number | string)[]"
{a: 1, b: "abc"}.tstype() "interface {\n  \"a\": number\n  \"b\": string\n}"
3n.tstype "bigint"
3.2n.tstype "fraction"
type, typeof get any value's type
null.type "null"
false.type "boolean"
3.type "number"
"".type "string"
().type "array"
{}.type "object"
123n.type "bigint"
1.4n.type "fraction"
y0 0th-order bessel y function
y1 1st-order bessel y function
yn(n, x) nth-order bessel y function
ymd2d parse a date string and get the day as a number
"2020-05-16".ymd2d 16
"2020/05/16".ymd2d 16
ymd2m parse a date string and get the month as a number
"2020-05-16".ymd2m 5
"2020/05/16".ymd2m 5
ymd2y parse a date string and get the year as a number
"2020-05-16".ymd2y 2,020
"2020/05/16".ymd2y 2,020

Examples of Evaluator Functions

all, every do all values satisfy the formula?
(1, 2, 3, 4, 5) . all(v % 2 == 0) false
any, some do any values satisfy the formula?
(1, 2, 3, 4, 5) . any(v % 2 == 0) true
assert, must ensure a (pre)condition holds
assert(123.type == "number") null
assert(123.type == "number", "not a number") null
call call a function by name
"c".call("hi", 123) ["hi", 123]
countif count how many values satisfy the formula
(1, 2, 3, 4, 5) . countif(v % 2 == 0) 2
def add/change global functions
def(tr, v => v.unless(v.sqrt)) null
def(f, (x, y) => log(abs(x/y))) null
def({
    f: (x, y) => `${x} + ${y} = ${x+y}`,
    g: str => str.trimmed(),
    h: (x, y, z) => x*y + z,
})
null
eval evaluate jeff source code
"5.iota . pow2".eval [2, 4, 8, 16, 32]
filter keep only the values satisfying the formula
(1, 2, 3, 4, 5) . filter(v % 2 == 0) [2, 4]
group, groupby split array/object by formula
(1, 2, 3, 4, 5) . group(v % 2) {"1"; [1, 3, 5], "0": [2, 4]}
keys get/transform keys from a container
map, mapkv transform values according to the formula
(1, 2, 3, 4, 5) . map(v % 2) [1, 0, 1, 0, 1]
(1, 2, 3, 4, 5) . map(v % 2 == 0) [false, true, false, true, false]
order, orderby, ordered, sort, sorted sort array/object using multiple criteria
("abc", "xyz", "def").sort [3.4, "abc", "def"]
("abc", "xyz", "def").sort ["abc", "def", "xyz"]
("abc", "xyz", "def").sort(v.len, -v) ["xyz", "def", "abc"]
("abc", "xyz", "def").sort(-v) ["xyz", "def", "abc"]
("abc", "xyz", "def").sort ["abc", "def", "xyz"]
rekey rename all object keys recursively
monthlen.rekey(k.lower[:3]).keys() ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]
ren, rename rename an object
{a: 123, b: 456}.rename(k + v) {"a123": 123, "b456": 456}
{a: 123, b: 456}.rename({a: `xyz`}) {"xyz": 123, "b": 456}
rev, revalue like map, but transforms basic values depth-first recursively, keeping the same general nested shape of the input
(1, 2, 3, 4, 5) . deepmap(v % 2) [1, 0, 1, 0, 1]
reverse, reversed reverse items, optionally transforming them via formulas
surgery recursively transform values of matching object keys
tally make a tally (count) of each distinct result the formula gives
(1, 2, 3, 4, 5) . tally(v % 2) {"1"; 3, "0": 2}
try, trycatch, tryexcept try expressions until one succeeds, or emit last error
try(3 + 3, "error fallback") 6
try(3 + 3n, "error fallback") "error fallback"
tryrevalue safe version of revalue, transforming basic values depth-first recursively, keeping the same general nested shape of the input
(1, 2, 3, 4, 5) . tryrevalue(v % 2) [1, 0, 1, 0, 1]
unless try 2nd expression, using the 1st if that fails
"error fallback".unless(3 + 3) 6
"error fallback".unless(3 + 3n) "error fallback"

Incomplete Examples

These examples are missing concrete input: use them in a pipe, or add a filename/URI with relevant data right after, and they'll do work.

Encode generic data into base64.

jf -from=bytes -to=text in.base64

Encode generic data into a data URI.

jf -from=bytes -to=text in.datauri

Decode base64 or data-URI text into raw bytes.

jf -from=text -to=bytes in.debase64

Compress generic data as gzip.

jf -from=bytes -to=bytes.gz

Decompress generic gzip data.

jf -from=bytes.gz -to=bytes

Decompress generic bzip2 data.

jf -from=bytes.bz -to=bytes

Restrict line-width of plain-text paragraphs up to 75 symbols per line.

jf -from=blocks -to=text '[squeeze(v^space).folds(75): in] ^ 2*lf'

Mimic the `strings` cmd-line app available on linux/mac.

jf -from=bytes -to=lines in.strings

Complete Examples

The following aliases can spare you a lot of typing when using Jeff directly:

Wondering how long float64 mantissas will work as unix-style timestamps... are those in millionths or billionths of a second?

jf -from=n '2**{52,53,64}/{1e6,1e9}/day/365.25+1970'

A partial ASCII table.

jf -from=n -to=ansi '{v: v.ord: space+visascii}'

Calculate how long do 4GB of PCM-audio (.wav files) last, under various settings.

jf -from=n -to=a '
    // msg(`How long do 4 GBs last as PCM sound (.wav) data?`) |
    {44_100, 48_000, 96_000} * {mono: 2, stereo: 4} | _ // bytes per second
    . revalue(data_rate => (4*gb/data_rate).s2hms) // convert into time durations
    . rename(k + ` hz`)'

Another way to do it.

jf -from=n -to=a '
    // msg(`How long do 4 GBs last as PCM sound (.wav) data?`);
    {44_100, 48_000, 96_000} * {mono: 2, stereo: 4}; // bytes per second
    4*gb/_; _@s2hms // convert into time durations
    . rename(k + ` hz`)'

Find how many KBs the commonest MP3/AAC fixed data-rates take per minute.

jf -from=n '{`128k`: 16, `192k`: 24} * {v.fix1: v: .5*20.iota} * 60'

Same as above, but using a more general formula.

jf -from=n '{`${64*v}k`: 8*v: 2..4} * {v.fix1: v: .5*20.iota} * 60'

You say ... about 1500 each day, what range is that a year?

jf -from=n 1500.fuzz*[365,366].kv

Now you tell me it's about 1400-1500 a day, so I guess you meant to say between 1400 and 1500 a day, which makes the yearly ranges...

jf -from=n [1400,1500].kv*[365,366].kv

Get me a nested/recursive list of filenames and their sizes starting from the current folder.

jf -to=a -from=n dot.fs

Now get me the flattened version of the same thing.

jf -to=a -from=n dot.fs^slash

Approximate e using its truncated-series expansions.

jf -from=n '{
    e,
    approx: a = 0 | (0..20).map(v, a = a + v.factorial.inv | a)
}'

Same, but use fractions for better accuracy, since using float64s exceeds the actual e fairly quickly. This example also shows how to do it using the special dictionary-builder syntax.

jf -from=n '{
    e,
    approx: a = 0n; {v: a = a + v.bigint.factorial.inv | a.n: 0..20}
}'

Emit ANSI-colored tiles from exponentially-distributed random values: the colorscale used conveys the relative intensity of each value to the highest value in each line/array.

jf -from=null -to=ansi "(`tput lines`-3) . map((`tput cols`-6) . map(rexp().tile) ^ '')"

Get date/time-related info for your timezone.

jf . https://worldtimeapi.org/api/ip

Get date/time-related info for your timezone, then ignore info about your own IP address, so it doesn't show in the result.

jf 'in . del(`client_ip`)' https://worldtimeapi.org/api/ip

Start JSON webserver on http://localhost:1234 to get the current date/time.

jf -from=null 'servejson(1234, now)'

Start webserver on http://localhost:1234 to get the current date/time.

jf -from=null 'servetext(1234, now.weekday[:3] + ` ` + now.string)'

Start JSON webserver on http://localhost:1234 with various live services.

jf -from=null 'servejson(1234, {
    `/`: `scripts are available at now/, pow2/, base64/, and debase64/`,
    now: now,           // the current date/time
    pow2: q.x.n.pow2,   // 2**x, given query parameter x
    base64: q.x.parse.base64, // base64-encode parameter x, a numeric JSON array
    debase64: q.x.debase64,   // base64-decode query parameter x
})'

Show colored tiles of increasing value.

jf -from=n -to=a '(0..50) . map((v/50).tile) . join . quote(nan.tile)'

A quick way to view a few base-10 logarithms, using ANSI styles/graphics.

jf -from=n -to=a '{
    log10: 10.map(v, v.log10.fix2 + space + v.log10.tile),
    trend: 10.map(v.log10).spark,
}'

A complete shell function to Group Digits by adding commas to make numbers more readable.

gd() { jf -from=el "in . fields . map(v.tryn.nice(${1:--1})) ^ ' '" "${@:2}"; }

A complete shell function to REPeat the text given.

rep() { jf -from=null "repeat('${1:--}', ${2:-80}, '${3:-}')"; }

Show 1-level-deep entries of the folder given, sorting entries by size, largest to smallest. All entries with NaN sizes are subfolders.

echo 'data/folder' | jf -from=text -to=ansi 'in.ls.sort(-v)'

Show file-tree from the folder given, sorting file entries inside the top-level subfolders by file size, largest to smallest.

echo 'data/folder' | jf -from=text -to=ansi 'in.fs  .  map(v.unless(v.sort(-v)))'

Reshape headlines/data from live reuters feed.

jf -to=ansi 'in.rss.channel[0].item .
    map({title: v.title, link: v.link, when: v.pubDate })' \
"https://news.google.com/rss/search?q=when:12h+allinurl:reuters.com&ceid=US:en&hl=en-US&gl=US"

Reshape headlines/data from live reuters feed, and show it on a new browser tab using my other apps `vida` (VIew DAta) and `si` (Show It).

jf 'in.rss.channel[0].item .
    map({title: v.title, link: v.link, when: v.pubDate })' \
"https://news.google.com/rss/search?q=when:12h+allinurl:reuters.com&ceid=US:en&hl=en-US&gl=US" |
    vida -from=json -to=html | si

Get URI for JSON exchange rates from the Bank of Canada, since the start of the month: using shell substitution effectively prevents using the string-interpolation syntax, which would interfere with the shell's own substitution syntax.

echo https://www.bankofcanada.ca/valet/observations/group/FX_RATES_DAILY/json?\
start_date=`jf -from=null 'now.year + "-" + now.month.pad02 + "-01"'`

Get recent `live` exchange rates from the Bank of Canada, and transform values from the latest record. The shell-injected use of the current year is to get a URI for data since the beginning of the current year: this avoids downloading data for several years, thus speeding up things.

jf -to=ansi 'latest = in.observations.last;
    rates = {k-`FX`-`CAD`: +v.v: latest.drop(`d`)};
    { date: latest.d, rates.sort(k)... }' \
    https://www.bankofcanada.ca/valet/observations/group/FX_RATES_DAILY/json?start_date=`date +%Y`-01-01

Same as before, but show only 4 decimals, and make values (now strings) look green as they did before.

jf -to=ansi 'latest = in.observations.last;
    rates = {k-`FX`-`CAD`: +v.v: latest.drop(`d`)};
    { date: latest.d, rates.sort(k)@fix4@green... }' \
    https://www.bankofcanada.ca/valet/observations/group/FX_RATES_DAILY/json?start_date=`date +%Y`-01-01

Calculate the first 100 fibonacci numbers: using bigint values allows using different limits without worries, since float64 starts giving wrong results at around 80 items. If float64s were used instead, this algorithm would be constant-space and linear-time.

echo 100 | jf 'a = 1n; b = 0n; in.map(v, b = a+b; a = b; b)'

Calculate prime numbers using the algorithm with O(n**1.5) time-complexity.

echo 100 | jf 'in
.filter(n => n != 1 && n.sqrt.all(div => div == 1 || n % div != 0))
.map((k+1).nth, v)'

Calculate prime numbers in streaming mode.

seq 100 | jf -from=ev '
    (in != 1 && n.sqrt.all(div => div == 1 || n % div != 0)) ? in : skip
' | nl

A prime-numbers calculator as a complete self-running shell script.

#!/usr/bin/env -S jf -f
// find all prime numbers up to the input number given

if(type(in) == `number`, in, error(`input must be a number`)) .
filter(n => n != 1 && n.sqrt . every(div => n % div != 0 || div == 1))

Turn lines from paragraph blocks into objects, using NaN values as filler values, instead of the default null values.

seq 17 | awk 'NR%5 == 1 { print "" }; 1' | jf -from=blocks '
    keys = `one,two,three,four,five` / `,`;
    // turn each string-array into an object
    [keys ^ v@n: in]
    // use nan as the default missing value, replacing null
    .revalue(v ?? nan)'

Rename all files in folders called `a`, `b`, and `c`, so they all lose their original filename extensions.

jf -from=n -to=l '
    [`mv ${v.shquo} ${v.trimsuffix(v.ext).shquo}`: argv.files]' a/ b/ c/ | sh

Show all linux/mac search-path folders one per line.

echo $PATH | jf -from=t -to=l in/colon

Show all windows search-path folders one per line.

echo %PATH% | jf -from=t -to=l in/semi

Template Examples

These examples involve using option `-t` with the files whose contents are shown below, with no command, as all commands are in the template given, and with optional input files/URIs as usual.

Templates from HTML/SVG files automatically HTML/SVG escape jeff results as they're inserted into the output, avoiding injection tricks from potentially hostile data sources you may load.

Emit info based on the current time/date: this template is run with no input files/URIs.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Simple HTML Template (<!--jf now.string -->)</title>
</head>

<body>
    <p>
        Right now it's
        <ul>
            <li><!--jf now[`hour`..`second`]@str@pad02.values() .join(`:`) --></li>
            <li><!--jf `${now.weekday[:3]}, ${now.day} ${now.monthname} ${now.year}` --></li>
        </ul>
    </p>
</body>

</html>

This one shows how to use a template loop, and is run with no input files/URIs.

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Looped HTML Template (<!--jf now.string -->)</title>
</head>

<body>
    <ul>
    <!-- Normal HTML/SVG comments like these will end up in the result. -->
    <!--
        When template jeff expressions result in a skip value, nothing from
        the line they're on will be part of the output, which is handy when
        you need to assign values but not emit an empty line because of it.
    -->
    <!--jf max = 12; skip -->
    <!--for key, val := 1..max -->
        <!--for name := `abc` -->
        <li><!--jf name -->: <!--jf key -->: <!--jf val --></li>
        <!--end -->
    <!--end -->
    </ul>
</body>

</html>

This example emits a partial ASCII table, and is run with no input files/URIs.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ASCII Table</title>
    <style>
        body {
            font-family: monospace;
        }

        .c {
            color: darkmagenta;
        }

        .n {
            color: dodgerblue;
            margin-right: 2rem;
        }

    </style>
</head>

<body>
    <!--jf rows = (space+visascii).runes.chunk(12).tr(); skip -->
    <table>
        <tbody>
            <!--for r := rows -->
            <tr>
                <!--for v := r -->
                <td><span class="c"><!--jf v --></span>: <span class="n"><!--jf v == nil ? skip : v.ord --></span></td>
                <!--end -->
            </tr>
            <!--end -->
        </tbody>
    </table>
</body>

</html>

Coming from Excel

excel closest jf concise jf
=CHAR(n) =char(n) n.char, n.rune
=LOWER(s) =lower(s) s.lower
=UPPER(s) =upper(s) s.upper
=TEXTBEFORE(s, t) =textbefore(s, t) s.textbefore(t)
=TEXTAFTER(s, t) =textafter(s, t) s.textafter(t)

Coming from SQL

SQL closest jf concise jf
select * from v order by x v.orderby(x) v.sort(x)
select * from v order by x asc, y desc v.orderby(x, -y) v.sort(x, -y)
printf("%s ...", x) x.str + ... `${x} ...`

Coming from JavaScript

javascript closest jf concise jf
null null nil
true true true
false false false
Math.E e e
Math.PI pi pi
NaN nan nan
Infinity infinity inf
isNaN(n) isnan(n) n.isnan
isFinite(n) isfinite(n) n.isfin
!isFinite(n) !isfinite(n) n.isinf
+s +s +s
a.reduce((x, y) => x + y) a.reduce(x + y) a.sum
a.reduce((x, y) => x * y) a.reduce(x * y) a.prod
Math.sin(n) sin(n) n.sin
x.toString() x.tostring() x.str()
s.toLowerCase() s.tolowercase(), s.tolowercase s.lower
s.toUpperCase() s.touppercase(), s.touppercase s.upper
s.replaceAll(t, "") s.replaceall(t, ""), s.replace(t, "") s - t
s.replaceAll(t, u) s.replaceall(t, u), s.replace(t, u) s / t ^ u
a.join(s) a.join(s), s.join(a) a ^ s, s ^ a
s.split(t) s.split(t) s / t
s.split("") s.split("") s.chars, s.runes, ^s, s / ""
String.fromCharCode(n) fromcharcode(n), chr(n) n.char, n.rune, n.chr
n.toString(2) n.tostring(2) n.bin
n.toString(8) n.tostring(8) n.oct
n.toString(16) n.tostring(16) n.hex
JSON.stringify(x) stringify(x) x.json()
JSON.parse(s) parse(s) s.parse
a.length a.length a.len
Object.keys(o) keys(o) o.keys()
Object.values(o) values(o) o...
c = 0; for (e of s) { c++ }; c s.count(true) s.len
a.map((v, k) => [k, v]) a.map((v, k) => [k, v]) a.map((k, v))
a[a.length - 2] a[a.length - 2] a[-2]
a.slice(0, Math.min(a.length, 8)) a.slice(0, min(a.length, 8)) a[:9], a.first9
a.slice(0, Math.min(a.length, 19)) a.slice(0, min(a.length, 19)) a[:20], a.first(20)
s.repeat(n) s.repeat(n) s * n
a.map(x => 125 * x) a.map(x => 125 * x) 125 * a
+s +s +s

Coming from Python

python closest jf concise jf
None none nil
True true true
False false false
math.e e e
math.pi pi pi
math.tau tau tau
math.nan nan nan
math.inf inf inf
string.whitespace whitespace whitespace
string.punctuation punctuation punctuation
string.digits digits digits
string.hexdigits hexdigits hexdigits
string.ascii_lowercase asciilowercase lower
string.ascii_uppercase asciiuppercase upper
string.ascii_letters asciiletters letters
math.isnan(n) isnan(n) n.isnan
math.isinf(n) isinf(n) n.isinf
float(s) float(s) +s
sum(a) sum(a) a.sum
prod(a) prod(a) a.prod
math.sin(n) sin(n) n.sin
str(x) str(x) str(x)
tolower(s) tolower(s) s.lower
toupper(s) toupper(s) s.upper
s.replace(t, "") s.replace(t, "") s - t
s.replace(t, u) s.replace(t, u) s / t ^ u
s.join((str(e) for e in a)) s.join(a), a.join(s) s ^ a, a ^ s
s.split(t) s.split(t) s / t
[e**2 for e in a] [e => e**2: a] a**2
[e for e in s] [e => e: s...] s..., s.chars, s.runes, s / ""
[tolower(e) for e in a] [e => tolower(e): a] a.lower
[[log2(f) for f in e] for e in a] [e => [f => log2(f): e]: a] a.log2
ord(s) ord(s) s.ord
bin(n) bin(n) n.bin
hex(n) hex(n) n.hex
json.dumps(x) dumps(x) x.json()
json.loads(s) loads(s) s.loads, s.parse
len(s) len(s) s.len
len(a) len(a) a.len
list(o.keys()) o.keys() o.keys()
list(o.values()) o.values() o...
list(enumerate(a)) enum(a) a.toent
list(range(n)) indices(n), indexes(n) n.ind
list(range(1, n+1)) seq(1, n) n.iota, 1..n
list(range(m, n+1)) seq(m, n) m..n
a[-2] a[-2] a[-2]
a[:min(len(a), 9)] a[:min(len(a), 9)] a[:9], a.first9
a[:min(len(a), 20)] a[:min(len(a), 20)] a[:20], a.first(20)
25 * s 25 * s 25 * s
[125 * e for e in a] [e => 125 * e: a] 125 * a

Function Names

A recent run of the following command results in the table below.

jf -from=null -to=html 'funcs().toentries().map({name: v[0], type: v[1]})'

963 rows
name type
empty string func(*Interpreter, []any)
! func(any)
!= func(any, any)
!== func(any, any)
!~ func([]any)
% func(any, any)
& func(any)
&& func(*Interpreter, []any)
* func([]any)
** func([]any)
+ func([]any)
- func([]any)
. func(*Interpreter, []any)
.. func(any, any)
... func(any)
.? func(*Interpreter, []any)
.@ func(*Interpreter, []any)
/ func(any, any)
; func(*Interpreter, []any)
< func(any, any)
<= func(any, any)
<> func(any, any)
= func(*Interpreter, []any)
== func(any, any)
=== func(any, any)
> func(any, any)
>= func(any, any)
?. func(*Interpreter, []any)
?: func(*Interpreter, []any)
?? func(*Interpreter, []any)
@ func(*Interpreter, []any)
[..] func(any, any, any)
[:] func(any, any, any)
[] func([]any)
\ func([]any)
^ func([]any)
abs func([]any)
acos func(float64)
acosh func(float64)
adapt func(any)
add func([]any)
add1 func(float64)
all func(*Interpreter, []any)
allkeys func(any)
allvalues func(any)
announce func([]any)
any func(*Interpreter, []any)
append func(any, any)
array func([]any)
asin func(float64)
asinh func(float64)
assert func(*Interpreter, []any)
assign func([]any)
asterisks func(any)
at func([]any)
atan func(float64)
atanh func(float64)
avoid func([]any)
awrap func(float64, float64, float64)
back func(*Interpreter, []any)
background func([]any)
backward func(*Interpreter, []any)
backwards func(*Interpreter, []any)
balls func(any)
barcode func([]any)
base64 func([]any)
basename func(string)
bat func([]any)
beta func(float64, float64)
bigint func(any)
bin func([]any)
blen func(any)
blength func(any)
blocks func(any)
blue func(any)
bmap func(*Interpreter, []any)
bool func(any)
boolean func(any)
break func(any, any)
break1 func(any)
break2 func(any)
break3 func(any)
break4 func(any)
break5 func(any)
break6 func(any)
break7 func(any)
break8 func(any)
break9 func(any)
bullets func(any)
byteat func([]any)
bytelen func(any)
bytelength func(any)
bytemap func(*Interpreter, []any)
bytes func(any)
bytes2uri func(any)
byteslice func(any, any, any)
bytexslice func(any, any, any)
call func(*Interpreter, []any)
capstr func(any, any)
capstrings func(any, any)
carets func(any)
cbrt func(float64)
cc func(string)
ccode func(string)
cdots func(any)
ceil func(float64)
ceiling func(float64)
centiles func(any)
cents func(any)
century func(float64)
char func([]any)
chars func(any)
chomp func(string)
chop func([]any)
chr func([]any)
chunk func(any, any)
chunk1 func(any)
chunk2 func(any)
chunk3 func(any)
chunk4 func(any)
chunk5 func(any)
chunk6 func(any)
chunk7 func(any)
chunk8 func(any)
chunk9 func(any)
circles func(any)
clamp func(float64, float64, float64)
color func([]any)
combine func([]any)
cond func(*Interpreter, []any)
contains func(string, string)
continent func(string)
cos func(float64)
cosh func(float64)
count func([]any)
countdecimals func(any)
countif func(*Interpreter, []any)
countpieces func([]any)
country func(string)
crlf func(any)
crosses func(any)
cube func([]any)
cubed func([]any)
cup2l func(float64)
cur func(string)
curcode func(string)
curr func(string)
currency func(string)
currencycode func(string)
cwd func([]any)
dashes func(any)
datauri func(any)
date2year func(any)
deappr func(any)
deapprox func(any)
debase64 func(any)
dec func(float64)
decade func(float64)
deciles func(any)
decr func(float64)
dedup func(any)
dedupe func(any)
deduped func(any)
def func(*Interpreter, []any)
default func([]any)
define func(*Interpreter, []any)
defn func(*Interpreter, []any)
deg func(float64)
deg2rad func(float64)
degrees func(float64)
dehtml func(string)
dehtmlify func(string)
del func([]any)
delattr func([]any)
delete func([]any)
denan func(any, any)
denil func([]any)
denom func(any)
denominator func(any)
denone func([]any)
denull func([]any)
deprefix func(string, string)
desc func(any)
describe func(any)
desuffix func(string, string)
dir func(any)
dirname func(string)
dirs func(any)
dollars func(any)
dots func(any)
dquo func(any)
dquote func(any)
drop func([]any)
dumps func(any)
dup func(any, any)
dup1 func(any)
dup2 func(any)
dup3 func(any)
dup4 func(any)
dup5 func(any)
dup6 func(any)
dup7 func(any)
dup8 func(any)
dup9 func(any)
dupe func(any, any)
duped func(any, any)
dur func(any)
duration func(any)
empty func(any)
endswith func([]any)
endswithany func([]any)
entries func(any)
enum func([]any)
eqfold func(string, string)
equalfold func(string, string)
erf func(float64)
erfc func(float64)
err func(any)
error func(any)
escuri func(string)
escurl func(string)
eval func(*Interpreter, []any)
evalpoly func([]any)
every func(*Interpreter, []any)
exp func(float64)
exp10 func(float64)
exp2 func(float64)
expm1 func(float64)
expovariate func([]any)
exslice func(any, any, any)
exslicebytes func(any, any, any)
ext func(string)
ext2mime func(string)
extend func(any, any)
extent func([]any)
f2c func(float64)
fac func([]any)
fact func([]any)
factorial func([]any)
fail func(any)
failure func(any)
fetch func(any)
fetchdata func(any)
fetchjson func(any)
fetchstr func(any)
fetchstring func(any)
fetchtext func(any)
fields func(any)
fileinfo func(any)
files func(any)
filetree func([]any)
filter func(*Interpreter, []any)
finfo func(any)
first func([]any)
first1 func(any)
first10 func(any)
first2 func(any)
first20 func(any)
first3 func(any)
first30 func(any)
first4 func(any)
first40 func(any)
first5 func(any)
first50 func(any)
first6 func(any)
first7 func(any)
first8 func(any)
first9 func(any)
fivenum func(any)
fivenums func(any)
fix func([]any)
fix0 func(any)
fix1 func(any)
fix2 func(any)
fix3 func(any)
fix4 func(any)
fix4json func(any)
fix5 func(any)
fix6 func(any)
fix7 func(any)
fix8 func(any)
fix9 func(any)
fixed func([]any)
fixed0 func(any)
fixed1 func(any)
fixed2 func(any)
fixed3 func(any)
fixed4 func(any)
fixed5 func(any)
fixed6 func(any)
fixed7 func(any)
fixed8 func(any)
fixed9 func(any)
flag func(string)
flat func(any)
flatkeys func([]any)
flatten func(any)
flattened func(any)
flattenkeys func([]any)
flip func(any)
float func([]any)
float64 func([]any)
floor func(float64)
fn func(*Interpreter, []any)
folders func(any)
folds func([]any)
foldstr func([]any)
foldstring func([]any)
for func(*Interpreter, []any)
foreach func(*Interpreter, []any)
from0 func(any)
from1 func(any)
fromcharcode func([]any)
froment func(any)
fromentries func(any)
fromjson func(any)
frowns func(any)
fs func([]any)
fsize func([]any)
fsizes func([]any)
ft2mt func(float64)
ftree func([]any)
ftype func(any)
func func(*Interpreter, []any)
funcs func(*Interpreter, []any)
fuzz func([]any)
ga2lt func(float64)
gal2l func(float64)
gamma func(float64)
gcd func([]any)
genstats func(any)
getattr func([]any)
globals func(*Interpreter, []any)
gray func(any)
green func(any)
group func(*Interpreter, []any)
groupby func(*Interpreter, []any)
hasanyprefix func([]any)
hasanysuffix func([]any)
hasprefix func([]any)
hasprefixany func([]any)
hassuffix func([]any)
hassuffixany func([]any)
head func([]any)
help func([]any)
hex func([]any)
hms2s func(any)
hole func(any)
horner func([]any)
html func(string)
htmlhttp func(*Interpreter, []any)
htmlify func(string)
hypot func([]any)
idem func(any)
iden func(any)
idiota func(any)
if func(*Interpreter, []any)
ifelse func(*Interpreter, []any)
ifs func(*Interpreter, []any)
ignore func([]any)
in2cm func(float64)
inc func(float64)
includes func(string, string)
incr func(float64)
indexes func(any)
indices func(any)
info func(any)
input func([]any)
int func(float64)
integer func(float64)
inv func([]any)
inverse func([]any)
invert func(any)
inverted func(any)
iota func(any)
isany func([]any)
isanyof func([]any)
isarray func(any)
isbool func(any)
isempty func(any)
isfin func(any)
isfinite func(any)
isinf func(any)
isnan func(any)
isnil func(any)
isnone func(any)
isnull func(any)
isnumber func(any)
iso2 func(string)
iso3 func(string)
isobject func(any)
isprime func(any)
isstring func(any)
join func([]any)
json func(any)
jsonhttp func(*Interpreter, []any)
keys func(any)
kv func(any)
kviota func(any)
last func([]any)
last1 func(any)
last10 func(any)
last2 func(any)
last20 func(any)
last3 func(any)
last30 func(any)
last4 func(any)
last40 func(any)
last5 func(any)
last50 func(any)
last6 func(any)
last7 func(any)
last8 func(any)
last9 func(any)
lb2kg func(float64)
lbeta func(float64, float64)
lcm func([]any)
leftpad func(string, int)
len func(any)
length func(any)
lf func(any)
lgamma func(float64)
limit func([]any)
limit1 func(any)
limit10 func(any)
limit2 func(any)
limit20 func(any)
limit3 func(any)
limit30 func(any)
limit4 func(any)
limit40 func(any)
limit5 func(any)
limit50 func(any)
limit6 func(any)
limit7 func(any)
limit8 func(any)
limit9 func(any)
limited func([]any)
linefeeds func(any)
lines func(any)
ln func(float64)
load func([]any)
loads func(any)
log func(float64)
log10 func(float64)
log1p func(float64)
log2 func(float64)
logistic func(float64)
lower func(string)
lowercase func(string)
lowercased func(string)
lowered func(string)
lpad func(string, int)
lpad1 func(any)
lpad2 func(any)
lpad3 func(any)
lpad4 func(any)
lpad5 func(any)
lpad6 func(any)
lpad7 func(any)
lpad8 func(any)
lpad9 func(any)
ls func([]any)
lsall func([]any)
lstrip func(string)
ltrim func(string)
mag func([]any)
magenta func(any)
magmify func([]any)
map func(*Interpreter, []any)
mapbytes func(*Interpreter, []any)
match func([]any)
matches func([]any)
max func([]any)
mballs func(any)
mdots func(any)
mediainfo func(any)
median func(any)
message func([]any)
metadata func(any)
mi2km func(float64)
mimetype func(any)
min func([]any)
miniballs func(any)
minmax func([]any)
minuses func(any)
minusplus func(any)
minusses func(any)
mod func(any, any)
month func(any)
month2n func(any)
month2num func(any)
mp func(any)
mpg2kpl func(float64)
msg func([]any)
mul func(any, any)
must func(*Interpreter, []any)
n func([]any)
name2mime func(string)
narrowtypes func(any)
nbytes func(any)
neg func([]any)
negate func([]any)
neutrals func(any)
nice func([]any)
nice0 func(any)
nice1 func(any)
nice2 func(any)
nice3 func(any)
nice4 func(any)
nice5 func(any)
nice6 func(any)
nice7 func(any)
nice8 func(any)
nice9 func(any)
nm2km func(float64)
nmi2km func(float64)
normalvariate func([]any)
not func(any)
notes func(any)
nth func([]any)
number func([]any)
numer func(any)
numerator func(any)
numstats func(any)
open func(any)
orange func(any)
ord func([]any)
orderby func(*Interpreter, []any)
oz2ml func(float64)
pad0 func(string, int)
pad01 func(any)
pad02 func(any)
pad03 func(any)
pad04 func(any)
pad05 func(any)
pad06 func(any)
pad07 func(any)
pad08 func(any)
pad09 func(any)
pair func(any, any)
parse func(any)
parsedate func(any)
parsedur func(any)
parseduration func(any)
parsejson func(any)
parulate func([]any)
pick func([]any)
pickpiece func([]any)
pink func(any)
playlen func(any)
playlength func(any)
playtime func(any)
plural func(string)
pluralize func(string)
pluses func(any)
plusminus func(any)
plusses func(any)
pm func(any)
poly func([]any)
polynomial func([]any)
polyval func([]any)
pop func(any)
popup func(any)
pow func([]any)
pow10 func(float64)
pow2 func(float64)
power func([]any)
pprintf func([]any)
prompt func([]any)
promptnum func([]any)
promptnumber func([]any)
promptstr func([]any)
promptstring func([]any)
psi2pa func(float64)
push func(any, any)
pwd func([]any)
quant func(any)
quantiles func(any)
quants func(any)
quosh func(string)
quote func([]any)
quotesh func(string)
r func([]any)
r0 func(float64)
r1 func(float64)
r2 func(float64)
r3 func(float64)
r4 func(float64)
r5 func(float64)
r6 func(float64)
r7 func(float64)
r8 func(float64)
r9 func(float64)
rad func(float64)
rad2deg func(float64)
radians func(float64)
rand func([]any)
random func([]any)
rec func([]any)
recip func([]any)
reciprocal func([]any)
red func(any)
region func(string)
regionus func(string)
rek func(*Interpreter, []any)
rekey func(*Interpreter, []any)
remainder func(float64, float64)
ren func(*Interpreter, []any)
rename func(*Interpreter, []any)
rep func([]any)
rep1 func(any)
rep2 func(any)
rep3 func(any)
rep4 func(any)
rep5 func(any)
rep6 func(any)
rep7 func(any)
rep8 func(any)
rep9 func(any)
repall func([]any)
repeat func([]any)
repeat1 func(any)
repeat2 func(any)
repeat3 func(any)
repeat4 func(any)
repeat5 func(any)
repeat6 func(any)
repeat7 func(any)
repeat8 func(any)
repeat9 func(any)
replace func([]any)
replaceall func([]any)
replacere func([]any)
repr func(any)
repre func([]any)
rerep func([]any)
reshape func([]any)
resplit func([]any)
rest func([]any)
rest1 func(any)
rest2 func(any)
rest3 func(any)
rest4 func(any)
rest5 func(any)
rest6 func(any)
rest7 func(any)
rest8 func(any)
rest9 func(any)
rev func(*Interpreter, []any)
reval func(*Interpreter, []any)
revalue func(*Interpreter, []any)
reverse func(*Interpreter, []any)
reversed func(*Interpreter, []any)
rexp func([]any)
rightpad func(string, int)
rnd func([]any)
rnorm func([]any)
round func([]any)
round0 func(float64)
round1 func(float64)
round2 func(float64)
round3 func(float64)
round4 func(float64)
round5 func(float64)
round6 func(float64)
round7 func(float64)
round8 func(float64)
round9 func(float64)
rounded func([]any)
rounded0 func(float64)
rounded1 func(float64)
rounded2 func(float64)
rounded3 func(float64)
rounded4 func(float64)
rounded5 func(float64)
rounded6 func(float64)
rounded7 func(float64)
rounded8 func(float64)
rounded9 func(float64)
rpad func(string, int)
rpad1 func(any)
rpad2 func(any)
rpad3 func(any)
rpad4 func(any)
rpad5 func(any)
rpad6 func(any)
rpad7 func(any)
rpad8 func(any)
rpad9 func(any)
rstrip func(string)
rtrim func(string)
rune func([]any)
runes func(any)
runif func([]any)
s2hms func([]any)
safeuri func(any)
safeurl func(any)
sballs func(any)
scale func([]any)
second func(any)
sel func([]any)
select func([]any)
seq func(any, any)
serve func(*Interpreter, []any)
servehtml func(*Interpreter, []any)
servejson func(*Interpreter, []any)
servesite func(*Interpreter, []any)
servetemplates func(*Interpreter, []any)
servetext func(*Interpreter, []any)
set func(any)
sharps func(any)
shift func(any)
shquo func(string)
shquote func(string)
shuf func([]any)
shuffle func([]any)
shuffled func([]any)
sign func([]any)
sin func(float64)
sinh func(float64)
skip func([]any)
skip1 func(any)
skip2 func(any)
skip3 func(any)
skip4 func(any)
skip5 func(any)
skip6 func(any)
skip7 func(any)
skip8 func(any)
skip9 func(any)
skipfirst func(any, any)
skipfirst1 func(any)
skipfirst2 func(any)
skipfirst3 func(any)
skipfirst4 func(any)
skipfirst5 func(any)
skipfirst6 func(any)
skipfirst7 func(any)
skipfirst8 func(any)
skipfirst9 func(any)
slashes func(any)
sleep func(any)
slice func(any, any, any)
slicebytes func(any, any, any)
slicex func(any, any, any)
smallballs func(any)
smiles func(any)
solveq func([]any)
solvequad func([]any)
some func(*Interpreter, []any)
sort func(*Interpreter, []any)
spaces func(any)
spark func(any)
sparkline func(any)
split func([]any)
splitre func([]any)
sqrt func(float64)
square func([]any)
squared func([]any)
squares func(any)
squeeze func(string)
squeezed func(string)
squish func(string)
squished func(string)
squo func(any)
squote func(any)
stars func(any)
startswith func([]any)
startswithany func([]any)
state func(string)
stateabbr func(string)
stateabbrev func(string)
stats func(any)
stderr func([]any)
stdout func([]any)
str func([]any)
strafter func(string, string)
strbefore func(string, string)
strcap func(any, any)
string func([]any)
stringify func(any)
strings func(any)
strip func(string)
stripped func(string)
stripprefix func(string, string)
stripsuffix func(string, string)
strsince func(string, string)
struntil func(string, string)
sub func([]any)
sub1 func(float64)
sum func(any)
swapkv func(any)
tabs func(any)
take func([]any)
takefirst func([]any)
takelast func([]any)
tally func(*Interpreter, []any)
tan func(float64)
tanh func(float64)
tbt func(*Interpreter, []any)
tbyt func(*Interpreter, []any)
textafter func(string, string)
textbefore func(string, string)
texthttp func(*Interpreter, []any)
textsince func(string, string)
textuntil func(string, string)
tildes func(any)
tile func(any)
tiles func(any)
title func(any)
titled func(any)
to func(any, any)
tobytes func(any)
tocharcode func([]any)
toent func(any)
toentries func(any)
tofixed func([]any)
tofixed0 func(any)
tofixed1 func(any)
tofixed2 func(any)
tofixed3 func(any)
tofixed4 func(any)
tofixed5 func(any)
tofixed6 func(any)
tofixed7 func(any)
tofixed8 func(any)
tofixed9 func(any)
tojson func(any)
tolower func(string)
tolowercase func(string)
ton2kg func(float64)
tooltip func(any)
tostr func([]any)
tostr10 func(any)
tostr11 func(any)
tostr12 func(any)
tostr13 func(any)
tostr14 func(any)
tostr15 func(any)
tostr16 func(any)
tostr2 func(any)
tostr3 func(any)
tostr4 func(any)
tostr5 func(any)
tostr6 func(any)
tostr7 func(any)
tostr8 func(any)
tostr9 func(any)
tostring func([]any)
tostring10 func(any)
tostring11 func(any)
tostring12 func(any)
tostring13 func(any)
tostring14 func(any)
tostring15 func(any)
tostring16 func(any)
tostring2 func(any)
tostring3 func(any)
tostring4 func(any)
tostring5 func(any)
tostring6 func(any)
tostring7 func(any)
tostring8 func(any)
tostring9 func(any)
toupper func(string)
touppercase func(string)
tr func(any)
tran func(any)
transpose func(any)
transposed func(any)
trim func(string)
trimafter func(string, string)
trimbefore func(string, string)
trimdec func(string)
trimdecimals func(string)
trimdecs func(string)
trimend func(string)
trimleft func(string)
trimmed func(string)
trimprefix func(string, string)
trimright func(string)
trimspace func(string)
trimspaces func(string)
trimstart func(string)
trimsuffix func(string, string)
trunc func(float64)
truncate func(float64)
truncated func(float64)
try func(*Interpreter, []any)
trycatch func(*Interpreter, []any)
tryexcept func(*Interpreter, []any)
tryjson func(any)
tryn func([]any)
trynumber func([]any)
tryp func(any)
tryparse func(any)
tryrev func(*Interpreter, []any)
tryreval func(*Interpreter, []any)
tryrevalue func(*Interpreter, []any)
tstype func(any)
type func(any)
typeof func(any)
unhtml func(string)
unhtmlify func(string)
uniform func([]any)
unique func(any)
unless func(*Interpreter, []any)
unprefix func(string, string)
unshift func(any, any)
unsuffix func(string, string)
unwrap func([]any)
update func([]any)
upper func(string)
uppercase func(string)
uppercased func(string)
uppered func(string)
upto func([]any)
utf8 func(any)
values func(any)
vars func(*Interpreter, []any)
view func(any)
viridize func([]any)
vk func(any)
walkdir func([]any)
walkdirs func([]any)
walkfolder func([]any)
walkfolders func([]any)
warn func(any)
wday func([]any)
weekday func([]any)
while func(*Interpreter, []any)
words func(any)
wrap func(float64, float64, float64)
xslice func(any, any, any)
yd2mt func(float64)
ymd2d func(any)
ymd2m func(any)
ymd2y func(any)
zeropad func(string, int)
zeropad1 func(any)
zeropad2 func(any)
zeropad3 func(any)
zeropad4 func(any)
zeropad5 func(any)
zeropad6 func(any)
zeropad7 func(any)
zeropad8 func(any)
zeropad9 func(any)
zpad func(string, int)
zpad1 func(any)
zpad2 func(any)
zpad3 func(any)
zpad4 func(any)
zpad5 func(any)
zpad6 func(any)
zpad7 func(any)
zpad8 func(any)
zpad9 func(any)
| func(*Interpreter, []any)
|> func(*Interpreter, []any)
|| func(*Interpreter, []any)
~ func([]any)
name type

Values

Before showing most variables, here are some special-use variables.

name type uses
_ any result of previous pipeline step; may start as the loaded input dataset
i number the current 0-based loop/item index
k number | string default name for the current key/index when looping over (transforming) a string, array, or object
v any default name for the current value when looping over (transforming) a string, array, or object
in any input data loaded either from standard input, or a mix of files and URIs
input any input data loaded either from standard input, or a mix of files and URIs
argv array all the file/URI input names given from the cmd-line, even if nothing was loaded when -from=null is used
now object parts of the current date/time when script starts running
q object query parameters when running as part of `servejson` or `servetext`

The following (shell) script created the table shown right after.

#!/bin/sh

# This script uses jf (Json Formulas) to show most of its built-in values,
# most of which come directly from this package's default values.

jf -from=null -to=html '
    max = 25;
    etc = ` ...`;
    globals()

    // variables `whitespace` and `printable` have a delete ASCII code in it;
    // some other strings are long enough to blow the width of the table
    . assign({
        _: nil,
        ascii: etc.reversed + ascii[32:32+max] + etc,
        asciiletters: asciiletters[:max] + etc,
        base64: base64[:max] + etc,
        dolorem: dolorem[:max] + etc,
        faces: faces[:max/2] + etc,
        letters: letters[:max] + etc,
        lorem: dolorem[:max] + etc,
        loremipsum: dolorem[:max] + etc,
        printable: printable[:max] + etc,
        visascii: visascii[:max] + etc,
        whitespace: whitespace[:-1],
    })

    // `example` widens the table
    . drop(`example`)

    // avoid objects with strings with ANSI escape codes
    //. drop(`ansi`, `style`, `styles`)

    . revalue((type(v) == `string` && v.contains(esc)) ? v+(v/esc^`ESC`)+reset-cr : v)
    . revalue(v == `<<skip value>>` ? `skip value`.gray : v)

    // omit details from arrays and objects, especially if they have many items
    . map(
        {t: type(v)} =>
            t == `array` ? `array (${v.len} items)`.orange :
            t == `object` ? `object (${len(v)} keys)`.magenta :
            v
    )

    // avoid all strings with ANSI escape codes
    //. filter(v.type() != `string` || !v.contains(esc))

    // turn to array of key-value pairs
    . toentries()

    // make those into an array of homogeneous objects, so they can be
    // rendered into HTML tables
    //. map({name: v[0], value: v[1], description: ``})
    . map({name: v[0], value: v[1]})
'

270 rows
name value
_ null
add +
amp &
ampersand &
and &
ansi object (12 keys)
argv array (0 items)
array array (0 items)
ascii
...  !"#$%&'()*+,-./012345678 ...
asciiletters ABCDEFGHIJKLMNOPQRSTUVWXY ...
asciilower abcdefghijklmnopqrstuvwxyz
asciilowercase abcdefghijklmnopqrstuvwxyz
asciiupper ABCDEFGHIJKLMNOPQRSTUVWXYZ
asciiuppercase ABCDEFGHIJKLMNOPQRSTUVWXYZ
ast *
asterisk *
at @
avoid skip value
backslash \
backtick `
ball ●
bang !
base64 ABCDEFGHIJKLMNOPQRSTUVWXY ...
bil 1,000,000,000
bill 1,000,000,000
billion 1,000,000,000
bin 01
bindigits 01
bingiga 1,073,741,824
binkilo 1,024
binmega 1,048,576
binpeta 1,125,899,906,842,624
binprefix 0b
bintera 1,099,511,627,776
block β–ˆ
blue ESC[38;5;33m
bquo `
bquote `
bslash \
btick `
bullet β€’
c 299,792,458
caret ^
cdot Β·
check βœ“
checkmark βœ“
circle ●
cire (?i)
cirep (?i)
colon :
comma ,
commaspace ,
continue skip value
cr
crlf

    
cross Γ—
cs ,
cup2l 0.236588236
dash –
data null
day 86,400
dec 0123456789
decdigits 0123456789
deg2rad 0.017453293
dict object (0 keys)
dictionary object (0 keys)
digits 0123456789
div Γ·
dollar $
dolorem Dolorem ipsum, quia dolor ...
done skip value
dot .
dquo "
dquote "
e 2.718281828
emark !
eps 0
epsilon 0
eq =
eql =
equ =
equal =
equals =
esc 
escape 
et &
etc ...
euro €
faces πŸ˜€πŸ˜πŸ˜‚πŸ˜ƒπŸ˜„πŸ˜…πŸ˜†πŸ˜‡πŸ˜ˆπŸ˜‰πŸ˜ŠπŸ˜‹ ...
false false
femto 0
flags object (249 keys)
frown πŸ™
ft2mt 0.304799990
fullblock β–ˆ
g 0.000000000
ga2lt 4.546090998
gal2l 4.546090998
gb 1,073,741,824
giga 1,000,000,000
gray ESC[38;5;245m
green ESC[38;5;28m
grin 😁
happy πŸ™‚
hash #
heart ❀️
hex 0123456789abcdefABCDEF
hexdigits 0123456789abcdefABCDEF
hexprefix 0x
hole β—‹
hour 3,600
hr 3,600
ignore skip value
in null
in2cm 2.54
inf ∞
infinity ∞
infstr ∞
infstring ∞
input null
invert ESC[7m
inverted ESC[7m
ire (?i)
irep (?i)
iso2 array (249 items)
kb 1,024
kilo 1,000
kv object (0 keys)
lb2kg 0.4535924
leapmonthdays object (12 keys)
leapmonthlen object (12 keys)
leapmonthlength object (12 keys)
letters ABCDEFGHIJKLMNOPQRSTUVWXY ...
lf
    
linefeed
    
lmondays object (12 keys)
lmonlen object (12 keys)
lmonthdays object (12 keys)
lmonthlen object (12 keys)
lmonthlength object (12 keys)
lorem Dolorem ipsum, quia dolor ...
loremipsum Dolorem ipsum, quia dolor ...
lower abcdefghijklmnopqrstuvwxyz
lowerhex 0123456789abcdef
lowerhexdigits 0123456789abcdef
lowerletters abcdefghijklmnopqrstuvwxyz
lowsquare β–„
lowtile β–„
magenta ESC[38;5;90m
max 25
maxint 9,007,199,254,740,992
maxsafeint 9,007,199,254,740,991
maxsafeinteger 9,007,199,254,740,991
mb 1,048,576
mball β€’
mdot Β·
mega 1,000,000
mi2km 1.609343980
micro 0.000001
milli 0.001
miniball β€’
minint -9,007,199,254,740,992
minsafeint -9,007,199,254,740,991
minsafeinteger -9,007,199,254,740,991
minus -
mol 602,214,085,700,000,000,000,000
monlen object (12 keys)
monthdays object (12 keys)
monthlen object (12 keys)
monthlength object (12 keys)
months array (12 items)
months1 array (13 items)
monweek array (7 items)
monweek1 array (8 items)
mpg2kpl 0.354006108
mul Γ—
music 🎡
nan NaN
nano 0.000000001
neutral 😐
newline
    
next skip value
nil null
nl
    
nm2km 1.852
nmi2km 1.852
none null
normal ESC[0m
note 🎡
nothing skip value
now object (10 keys)
null null
object object (0 keys)
oct 01234567
octdigits 01234567
octprefix 0o
orange ESC[38;5;166m
oz2ml 29.573529562
pb 1,125,899,906,842,624
percent %
peta 1,000,000,000,000,000
phi 1.618033989
pi 3.141592654
pico 0.000000000
pink ESC[38;5;206m
pipe |
plus +
pow2 Β²
pow3 Β³
power2 Β²
power3 Β³
printable ABCDEFGHIJKLMNOPQRSTUVWXY ...
psi2pa 6,894.757280000
punctuation !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
qmark ?
que ?
question ?
rad2deg 57.295779513
red ESC[38;5;124m
reset ESC[0m
root null
sad πŸ™
sball β€’
semi ;
semicolon ;
sharp #
skip skip value
slash /
smallball β€’
smile πŸ™‚
space
square β– 
squo '
squote '
star ⭐
str empty string
string empty string
styles object (12 keys)
sub -
sum Ξ£
sunweek array (7 items)
sunweek1 array (8 items)
tab
	
tau 6.283185307
tb 1,099,511,627,776
tera 1,000,000,000,000
tilde ~
tile β– 
times Γ—
ton2kg 0.001102311
tril 1,000,000,000,000
trill 1,000,000,000,000
trillion 1,000,000,000,000
true true
undef skip value
undefined skip value
under _
underscore _
upper ABCDEFGHIJKLMNOPQRSTUVWXYZ
upperhex 0123456789ABCDEF
upperhexdigits 0123456789ABCDEF
upperletters ABCDEFGHIJKLMNOPQRSTUVWXYZ
vbar |
visascii !"#$%&'()*+,-./0123456789 ...
void skip value
week 604,800
weekdays array (7 items)
whitespace
 	
    
wk 604,800
yd2mt 0.914400249
name value