From 6b268c5df42c757ea84e1c0d526106c93a04af58 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sun, 3 Jan 2021 09:32:59 -0600 Subject: [PATCH] `find-index` now takes optional default. --- CHANGELOG.md | 5 ++++- src/boot/boot.janet | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d42e893..2cda5516 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,15 @@ All notable changes to this project will be documented in this file. ## Unreleased - ??? +- Add `dflt` argument to find-index. - Add `:all` keyword to `ev/read` and `net/read` to make them more like `file/read`. However, we do not provide any `:line` option as that requires buffering. - Change repl behavior to make Ctrl-C raise SIGINT on posix. The old behavior for Ctrl-C, to clear the current line buffer, has been moved to Ctrl-Q. - Importing modules that start with `/` is now the only way to import from project root. - Before, this would import from / on disk. + Before, this would import from / on disk. Previous imports that did not start with `.` or `/` + are now unambiguously importing from the syspath, instead of checking both the syspath and + the project root. This is backwards incompatible and dependencies should be updated for this. - Change hash function for numbers. - Improve error handling of `dofile`. diff --git a/src/boot/boot.janet b/src/boot/boot.janet index c8be62fc..58281d39 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -1026,10 +1026,10 @@ (error "expected 1 to 3 arguments to range"))) (defn find-index - `Find the index of indexed type for which pred is true. Returns nil if not found.` - [pred ind] + `Find the index of indexed type for which pred is true. Returns dflt if not found.` + [pred ind &opt dflt] (var k nil) - (var ret nil) + (var ret dflt) (while true (set k (next ind k)) (if (= k nil) (break))