mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 07:33:01 +00:00 
			
		
		
		
	Add from-pairs to core. #683
				
					
				
			This always creates a table, use `table/to-struct` to create a struct.
This commit is contained in:
		| @@ -1,6 +1,9 @@ | |||||||
| # Changelog | # Changelog | ||||||
| All notable changes to this project will be documented in this file. | All notable changes to this project will be documented in this file. | ||||||
|  |  | ||||||
|  | ## ??? - Unreleased | ||||||
|  | - Add `from-pairs` to core. | ||||||
|  |  | ||||||
| ## 1.15.5 - 2021-04-25 | ## 1.15.5 - 2021-04-25 | ||||||
| - Add `declare-headers` to jpm. | - Add `declare-headers` to jpm. | ||||||
| - Fix error using unix pipes on BSDs. | - Fix error using unix pipes on BSDs. | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ | |||||||
|  |  | ||||||
| project('janet', 'c', | project('janet', 'c', | ||||||
|   default_options : ['c_std=c99', 'build.c_std=c99', 'b_lundef=false', 'default_library=both'], |   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 | # Global settings | ||||||
| janet_path = join_paths(get_option('prefix'), get_option('libdir'), 'janet') | janet_path = join_paths(get_option('prefix'), get_option('libdir'), 'janet') | ||||||
|   | |||||||
| @@ -1525,6 +1525,15 @@ | |||||||
|   (loop [k :keys dict] (array/push ret k (in dict k))) |   (loop [k :keys dict] (array/push ret k (in dict k))) | ||||||
|   ret) |   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 | (defn interpose | ||||||
|   `Returns a sequence of the elements of ind separated by |   `Returns a sequence of the elements of ind separated by | ||||||
|   sep. Returns a new array.` |   sep. Returns a new array.` | ||||||
|   | |||||||
| @@ -5,9 +5,9 @@ | |||||||
|  |  | ||||||
| #define JANET_VERSION_MAJOR 1 | #define JANET_VERSION_MAJOR 1 | ||||||
| #define JANET_VERSION_MINOR 15 | #define JANET_VERSION_MINOR 15 | ||||||
| #define JANET_VERSION_PATCH 5 | #define JANET_VERSION_PATCH 6 | ||||||
| #define JANET_VERSION_EXTRA "" | #define JANET_VERSION_EXTRA "-dev" | ||||||
| #define JANET_VERSION "1.15.5" | #define JANET_VERSION "1.15.6-dev" | ||||||
|  |  | ||||||
| /* #define JANET_BUILD "local" */ | /* #define JANET_BUILD "local" */ | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose