Skip to content

Latest commit

 

History

History
178 lines (177 loc) · 5.6 KB

changes.org

File metadata and controls

178 lines (177 loc) · 5.6 KB

Conf options

  • JANET_NO_NET
  • JANET_NO_INT_TYPES
  • JANET_NO_EV
  • JANET_NO_THREADS

Todos

better loop macro

Additions

Math

Bitwise operations

  • bflip
  • bstr

Shell

$
run a command, return output
$*
run many commands, return output
  • For either of the previous two commands, if the last arg is :sh, then eval by passing to the system shell. Prints output, returns nil.
  • For either of the previous two commands, any item beginning with the “$” character is evaluated literally.
cli
small macro that wraps any number of lisp forms in a main function and exposes an array called `args` that contains the command line arguments. Included to make writing scripts more concise.

Predicates

is-len?
checks if collection is length
hasone?
coll has exactly one element

File

file<-
read full file and close
file->
write file and close
file+
file append and close
file-each-line
takes file pointer f and a list of forms, executes all forms on every line of the file.
awk-file
accepts a table of actions and a file name (string) or file. Table should have PEGs as keys and a single form as a value. Form is run on every line of the file that matches the PEG, results are collected and returned as an array. The form has access to
  • NF (num fields)
  • a function f which gets a field (shorthand _),
  • a function n which gets a field and reads it as a number,
  • wds a list of words
  • wdsn a list of words as numbers
  • line which is the line after trimming.
awk
uses awk-file on stdin. meant for cli usage, no need to quote table.
awk-str
same as awk-file but takes a string as second argument.

Collections and functional stuff

  • head, tail functions
idx
get with flipped arguments. supports negative indexing
flip
reverse the order of arguments of a function
fst
first
snd
second
id
return arg
mapf
accepts a lisp form in place of a function and inserts it into a nullary lambda.
nullary
accepts a lisp form and inserts it into a nullary lambda (so, it returns a function with no arguments that just runs your code.)
funcn
applies a function f to collection at an index
bifunc1
applies a function to the first element of something. shorthand for a common application of funcn
bifunc2
same thing, pretty much.

Arrow improvements

improved ->>
Prefixing any threaded form with * flips the arg order of the function.
-< and -<<
Furculas from swiss-arrows by rplevy. New syntactic structure to capture the structure of branching data-passing. See the implementation of s-break for an example in the source.

Strings

s:>
slice from beginning of string until find (excluding find)
s>:
slice from find (including find) until the end of string
s>:>
slice from second arg to third arg in first arg
lines
split by \n
words
split by whitespace
s+
concat strings with extra shorthand variables, namely
  • qt for the escaped double quote, because it’s a PITA to type in lisp
  • sqt for single quote
  • nl for escaped new line
  • tb for escaped tab character
  • s for space
s-break
partition a string into an array of two strings at an index
s->/
equivalent to python’s partition function
s/<-
equavalent to python’s rpartition function
basename
strips path and file extension from a string

PEG

peg>!*
peg match all
extra default patterns
(any) forms for S W A D H.

Misc

m cli option
run a string of janet code, expose ipt as stdin text.

Renaming

Arrays

array/new
arr-new
array/new-filled
arr-new*
array/fill
arr*
array/pop
arr->
array/peek
arr-peek
array/push
arr<-
array/ensure
arr-ensure
array/slice
arr:
array/concat
arr+
array/insert
arr!
array/remove
arr-
array/trim
arr><
array/clear
arr_

Tuples

tuple/brackets
tup-brackets
tuple/slice
tup:
tuple/type
tup-type
typle/sourcemap
tup-sourcemap
tuple/setmap
tup-setmap

Tables

table/new
tab-new
  • table/to-struct, table/getproto, table/setproto, table/rawget, table/proto-flatten all changed to tab-
table/clone
tab&
table/clear
tab_

PEG

peg/compile
peg-compile
peg/match
peg>!
peg/find
peg>
peg/find-all
peg>*
peg/replace
peg/>
peg/replace-all
peg/>*

Buffer

buffer/new
buf-new
buffer/new-filled
buf-new*
buffer/fill
buf*
buffer/trim
buf//
buffer/push-byte
buf<-byte
buffer/push-word
buf<-word
buffer/push-string
buf<-str
buffer/push
buf<-
buffer/popn
buf-popn
buffer/clear
buf_
buffer/slice
buf:
buffer/bit-set
buf-bit-set
buffer/bit-clear
buf-bit_
buffer/bit-toggle
buf-bit-toggle
buffer/blit
buf-blit
buffer/format
buf-fmt

String

string/slice
s:
keyword/slice symbol/slice
key: sym:
string/repeat
s*
string/bytes
s-bytes
string/from-bytes
s-from-bytes
string/ascii-lower
s_
string/ascii-upper
s^
string/reverse
s<->
string/find
s>
string/find-all
s>*
string/has-prefix?
s-prefix?
string/has-suffix?
s-suffix?
string/replace
s/>
string/replace-all
s/>*
string/split
s/
string/check-set
s-check-set
string/join
s-join
string/format
s-fmt
string/trim
s//
string/triml
s/-
string/trimr
s-/

File

  • All file functions have / changed to -

Math

  • All functions and constants have math/ stripped
math/next
next-after

Macros

defn
defun

Other

reduce2
foldl
scan-number
s->n

Not renamed:

  • fiber
  • parser