Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Last active April 13, 2025 08:21
Show Gist options
  • Save sogaiu/0b35b02dca7eb4204667eee6e39d0421 to your computer and use it in GitHub Desktop.
Save sogaiu/0b35b02dca7eb4204667eee6e39d0421 to your computer and use it in GitHub Desktop.
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
  • take-until - tuple, string, table (undocumented), or array
  • drop - tuple, string, table (undocumented), struct (undocumented), or array
  • drop-until - tuple, string, table (undocumented), struct (undocumented), or array
  • drop-while - tuple, string, table (undocumented), struct (undocumented), or array
  • reverse - array or buffer

return type does not vary based on type of input

new array

  • sorted
  • sorted-by
  • accumulate
  • accumulate2
  • map
  • mapcat
  • filter
  • keep
  • keys
  • values
  • pairs
  • partition-by
  • interleave
  • distinct
  • flatten
  • kvs
  • interpose
  • partition

in-place mutation of input argument into (array)

  • flatten-into

non-negative integer

  • count

new tuple

  • juxt

new table

  • invert
  • zipcoll
  • merge
  • frequencies
  • group-by
  • from-pairs

returns in-place mutation of input argument tab (table)

  • merge-into

return type not as formulaic

  • reduce - returns in-place mutation of input argument init
  • reduce2 - returns result of series of computations
  • find-index - returns non-negative integer, nil, or input argument dflt
  • find - returns value in input argument ind, nil, or input argument dflt
  • index-of - returns key in input argument ind or input argument dflt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment