Add `from-pairs` to core. #683

This always creates a table, use `table/to-struct` to
create a struct.
This commit is contained in:
Calvin Rose 2021-04-29 12:06:24 -05:00
parent e181ee586b
commit 8fc8974b60
4 changed files with 16 additions and 4 deletions

View File

@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.
## ??? - Unreleased
- Add `from-pairs` to core.
## 1.15.5 - 2021-04-25
- Add `declare-headers` to jpm.
- Fix error using unix pipes on BSDs.

View File

@ -20,7 +20,7 @@
project('janet', 'c',
default_options : ['c_std=c99', 'build.c_std=c99', 'b_lundef=false', 'default_library=both'],
version : '1.15.5')
version : '1.15.6')
# Global settings
janet_path = join_paths(get_option('prefix'), get_option('libdir'), 'janet')

View File

@ -1525,6 +1525,15 @@
(loop [k :keys dict] (array/push ret k (in dict k)))
ret)
(defn from-pairs
``Takes a sequence of pairs and creates a table from each pair. The inverse of
`pairs` on a table.``
[ps]
(def ret @{})
(each [k v] ps
(put ret k v))
ret)
(defn interpose
`Returns a sequence of the elements of ind separated by
sep. Returns a new array.`

View File

@ -5,9 +5,9 @@
#define JANET_VERSION_MAJOR 1
#define JANET_VERSION_MINOR 15
#define JANET_VERSION_PATCH 5
#define JANET_VERSION_EXTRA ""
#define JANET_VERSION "1.15.5"
#define JANET_VERSION_PATCH 6
#define JANET_VERSION_EXTRA "-dev"
#define JANET_VERSION "1.15.6-dev"
/* #define JANET_BUILD "local" */