JA(1)

πŸ“¦ version 3.3.0.6, in nixos 26.05, nixpkgs unstable

πŸ’– ja(1) β€” Jacinda πŸ’–

okay bestie, this is the manual page for ja β€” Jacinda: data filtering, processing, reporting. It's giving β€œAWK but make it a whole vibe,” and I'm here to walk you through every flag and builtin without losing a single crumb. 🫢


🌸 NAME 🌸

ja β€” Jacinda: data filtering, processing, reporting.

✨ SYNOPSIS ✨

ja run src.jac -i data.txt

cat FILE1 FILE2 | ja '#"$0'

ja tc script.jac

ja e '11.67*1.2'

πŸ¦‹ DESCRIPTION πŸ¦‹

Jacinda is a data stream processing language Γ  la AWK. Literally that's the description, and it's iconic.

πŸ’… SUBCOMMANDS πŸ’…

  • run β€” run a program from file.
  • tc β€” typecheck a program.
  • e β€” evaluate an expression (without reference to a file).

πŸŽ€ OPTIONS πŸŽ€

  • -h, --help β€” display help.
  • -V, --version β€” display version information.
  • -I, --include β€” include directory for imports.
  • -F β€” field separator regex.
  • -R β€” record separator regex.
  • --csv β€” process as CSV.
  • -b, --header β€” include match when splitting records.
  • -Dfile=main.c β€” define variable.

🧚 LANGUAGE 🧚

πŸ”₯ REGEX πŸ”₯

Regular expressions follow Rust’s regex library: https://docs.rs/regex/. no cap, that's the regex lore.

πŸ’€ BUILTINS πŸ’€

Okay this is the builtin buffet β€” every single one, exactly like the source, with the type signatures preserved. ⭐

  • :i β€” postfix operator: parse integer.
  • :f β€” postfix operator: parse float.
  • : β€” postfix operator: parse, inferring type.
  • # β€” prefix operator: tally (count bytes in string).
  • #* β€” prefix operator: list length; List a -> a.
  • , β€” ternary operator: zip with; (a -> b -> c) -> Stream a -> Stream b -> Stream c.
  • | β€” ternary operator: fold; Foldable f :=> (b -> a -> b) -> b -> f a -> b.
  • |> β€” fold without seed; Foldable f :=> (a -> a -> a) -> f a -> a.
  • ^ β€” ternary operator: scan; (b -> a -> b) -> b -> Stream a -> Stream b.
  • ^* β€” scan (list); (b -> a -> b) -> b -> List a -> List b.
  • ", Β¨ β€” binary operator: map; Functor f :=> a -> b -> f a -> f b.
  • [: β€” unary operator: const; a -> b -> a.
  • #. β€” binary operator: filter; Witherable f :=> (a -> Bool) -> f a -> f a.
  • \. β€” binary operator: prior; (a -> a -> b) -> Stream a -> Stream b.
  • ~. β€” unary deduplication (stream); Ord a :=> Stream a -> Stream a.
  • ~.* β€” deduplicate on (stream); Ord b :=> (a -> b) -> Stream a -> Stream a.
  • max β€” maximum of two values; Ord a :=> a -> a -> a.
  • min β€” minimum of two values; Ord a :=> a -> a -> a.
  • & β€” boolean and.
  • || β€” boolean or.
  • ! β€” prefix boolean not.
  • ~ β€” matches regex; Str -> Regex -> Bool.
  • !~ β€” does not match; Str -> Regex -> Bool.
  • ix, ⍳ β€” line number.
  • substr β€” extract substring; Str -> Int -> Int -> Str.
  • sub1 β€” substitute first occurrence; Regex -> Str -> Str -> Str.
  • subs β€” substitute all occurrences; Regex -> Str -> Str -> Str.
  • split β€” split a string by regex; Str -> Regex -> List Str.
  • splitc β€” split a string on a single character; Str -> Str -> List Str.
  • ⌊, |. β€” floor function; Float -> Int.
  • Ceiling function β€” symbols:
⌈, |`

type: Float -> Int.

  • -. β€” unary negate.
  • sprintf β€” convert an expression to a string using the format string; %f float, %i integer, %s string, %b boolean.
  • option β€” option eliminator; b -> (a -> b) -> Option a -> b.
  • match β€” Str -> Regex -> Option (Int . Int).
  • ~? β€” maybe match: return string if it is a match, otherwise None; Str -> Regex -> Option Str.
  • ~* β€” match, returning nth capture group; Str -> Int -> Regex -> Option Str.
  • captures β€” return all aptures (nth capture group); Str -> Int -> Regex -> List Str.
  • :? β€” mapMaybe; Witherable f :=> (a -> Option b) -> f a -> f b.
  • .? β€” catMaybes; Witherable f :=> f (Option a) -> f a.
  • fp β€” filename.
  • nf β€” number of fields.
  • ⍬ β€” empty string/empty list.
  • head#, last# β€” List a -> a.
  • tail#, init# β€” List a -> List a.
  • drop#, take# β€” Int -> List a -> List a.

πŸ¦‹ SYNTAX πŸ¦‹

  • 'str' β€” string literal.
  • /pat/ β€” regex literal.
  • `n β€” nth field.
  • `0 β€” current line.
  • `* β€” last field.
  • `$ β€” all fields; List Str.
  • $n β€” nth column.
  • $0 β€” stream of lines.
  • {%<pattern>}{<expr>} β€” filtered stream on lines matching <pattern>, defined by <expr>.
  • {<expr>}{<expr>} β€” filtered stream defined by <expr>, on lines satisfying a boolean expression.
  • {|<expr>} β€” stream defined by <expr>.
  • #t β€” boolean literal.
  • _n β€” negative number.
  • .n β€” extract the nth value; List a -> a.
  • ->n β€” get the nth element of a tuple.
  • `{. β€” line comment.
  • @include'/path/file.jac’ β€” file include.
  • ?<expr>; <expr>; <expr> β€” if... then... else.
  • <pattern>,,<pattern> <expr> β€” bookend a stream.
  • <expr> $> <expr> β€” print stream and summary result.
  • fn f(x, y) := x + y; β€” function definition.
  • let val x := y + 1 in x end β€” let binding.
  • (<expr> . <expr> . ... . <expr>) β€” tuple.
  • #{ <fieldname> .= <expr>; ... <fieldname> .= <expr> } β€” record literal.

πŸŽ€ DECLARATIONS πŸŽ€

  • :set fs=/REGEX/; β€” set field separator.
  • :set rs=/REGEX/; β€” set record separator.
  • :set header; β€” include match when splitting records.
  • :set csv; β€” process as CSV.
  • :flush; β€” flush stdout for every line.

🌈 INFLUENTIAL ENVIRONMENT VARIABLES 🌈

  • JAC_PATH β€” colon-separated list of directories to search for imports.

πŸ“ EXAMPLES πŸ“

  1. Print lines longer than 72 bytes:
[#x>72] #. $0
  1. Print lines longer than 72 bytes:
{#`0>72}{`0}
  1. Select only the third line:
{ix=3}{`0}
  1. Present column names of a .csv file:
:set csv; {ix=1}{[x+'\n'+y]|>`$}
  1. Sum first column:
(+)|0 $1:i
  1. Count lines:
(+)|0 [:1"$0
  1. Count lines:
[y]|> {|ix}
  1. Count bytes (+1 for newlines):
(+)|0 [#x+1]"$0
  1. Count bytes:
(+)|0 {|#`0+1}
  1. Display with line numbers:
{|sprintf '%i: %s' (ix.`0)}
  1. Is the first column strictly increasing?
(&)|#t (>)\. {|`1:f}
  1. Is the last line blank?
[y]|> {|`0~/^$/}
  1. Trim trailing whitespace:
{|option ⍬ [x] (`0 ~* 1 /^((\s+\S|\S)*)\s*$/)}
  1. Concatenate into one line, discarding leading whitespace between:
ja -R'\n\s*' "[x+' '+y]|>\$0"

πŸ’€ BUGS πŸ’€

bestie, if you find a bug, please report it to https://github.com/vmchale/jacinda/issues β€” that's the exact link from the page. 🫢

Copyright 2021-2022. Vanessa McHale. All Rights Reserved.

🌟 AUTHORS 🌟

Vanessa McHalevamchale@gmail.com


okay that's the whole ja(1) page. The footer has no extra source/version or date listed beyond the manual name, so this is the cute sign-off: stay streaming, stay slaying, and may your regexes always be valid. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from