Skip to content

Instantly share code, notes, and snippets.

@sogaiu
sogaiu / janet-docstring-constructs.md
Last active April 18, 2025 11:27
desired constructs for janet docstrings

Background

Some notes on features that might be nice to have for Janet docstrings. The existing docstrings exhibit a number of features but as there was no convention established early on nor any automation, existing docstrings vary a bit.

Below are some descriptions of features along with concrete examples from existing Janet docstrings.

@sogaiu
sogaiu / test.md
Last active April 15, 2025 11:19
html (and markdown-ish) list item illusions

exhibit a

  • one item
  • another item
  • third item

exhibit b

  • one item
@sogaiu
sogaiu / janet-doc-format-notes.md
Last active April 15, 2025 11:17
janet doc-format notes

Background

Janet's docstrings "support some subset of Markdown"...but exactly what?

Notes

# XXX:
#
# * spork/pm.janet's resolve-bundle has a docstring that looks like
# it might eventually end up with a nested list.
#
# * could a nested list item end up looking like an ordinary "indented"
# line?
# assumes source has been formatted with doc-format such that there is
# no indentation and no color (which implies list item markers have
@sogaiu
sogaiu / return-values-of-some-janet-callables.md
Last active April 13, 2025 08:21
notes on return values of some janet callables

Notes on Return Values of Some Janet Callables

return type varies based on type of input

in-place mutation of input argument

  • sort - buffer, array, table
  • sort-by - buffer, array, table (undocumented)
  • reverse! - buffer, array, table (undocumented)

new value

  • take - tuple, string, table (undocumented), or array
  • take-while - tuple, string, table (undocumented), or array
@sogaiu
sogaiu / links.md
Last active April 11, 2025 10:06
janet docstrings that use more than paragraphs
@sogaiu
sogaiu / docstring.janet
Last active April 11, 2025 09:17
tweaked mendoza.janet from initial commit of mendoza
# parse docstring's flavor of markdown
# based on initial commit of mendoza by bakpakin
(defn- combine-strings
"Flatten consecutive strings in an indexed structure by concatenating
them. The resulting document graph should be much cleaner. Also, empty
strings will be removed entirely."
[els]
(def buf @"")
@sogaiu
sogaiu / product.janet
Created April 9, 2025 05:41
on calling something a hack...
(defn int-product
[x y]
(defn helper
[counter total]
(if (zero? counter)
total
(helper (dec counter) (+ total y))))
#
(helper x 0))
@sogaiu
sogaiu / short-fn-trickiness.janet
Last active April 9, 2025 04:41
janet $0, $1, ..., $& trickiness
(|[$0 $1] 1 0)
# =>
[1 0]
(|[$&] 1 0)
# =>
[[1 0]]
(|[$0 $1 $&] 1 0)
# =>