Skip to content

Commit 3ce080d

Browse files
authored
Add support for fnext core function (#880)
Hi, can you please consider patch to add support for Clojure's `fnext` fn. It resolves #879. Thanks Co-authored-by: ikappaki <[email protected]>
1 parent cd2b7b9 commit 3ce080d

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
* Added `==` as an alias to `=` (#859)
1616
* Added custom exception formatting for `basilisp.lang.compiler.exception.CompilerException` and `basilisp.lang.reader.SyntaxError` to show more useful details to users on errors (#870)
1717
* Added `merge-with` core function (#860)
18+
* Added `fnext` core function (#879)
1819

1920
### Changed
2021
* Cause exceptions arising from compilation issues during macroexpansion will no longer be nested for each level of macroexpansion (#852)

src/basilisp/core.lpy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,11 @@
461461
[v]
462462
(next (first v)))
463463

464+
(defn ^:inline fnext
465+
"Return the result of calling ``(first (next v))``\\."
466+
[v]
467+
(first (next v)))
468+
464469
(defn ^:inline nnext
465470
"Return the result of calling ``(next (next v))``\\."
466471
[v]

tests/basilisp/test_core_fns.lpy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@
233233
;; Collection Functions ;;
234234
;;;;;;;;;;;;;;;;;;;;;;;;;;
235235

236+
(deftest fnext-test
237+
(is (= nil (fnext [])))
238+
(is (= nil (fnext [1])))
239+
(is (= nil (fnext [1 nil])))
240+
241+
(is (= 2 (fnext [1 2])))
242+
(is (= [2] (fnext [1 [2] 3]))))
243+
236244
(deftest bounded-count-test
237245
(are [x n y] (= x (bounded-count n y))
238246
0 5 []

0 commit comments

Comments
 (0)