Skip to content
Snippets Groups Projects
Commit dfb293b8 authored by Simon Belak's avatar Simon Belak
Browse files

Nil pad results of last-n when (count seq) < n

parent ce03bfa2
Branches
Tags
No related merge requests found
......@@ -11,7 +11,8 @@
[n]
(fn
([] [])
([acc] acc)
([acc]
(concat (repeat (- n (count acc)) nil) acc))
([acc x]
(if (< (count acc) n)
(conj acc x)
......
......@@ -15,9 +15,21 @@
first
:last-value))
(expect
700
(-> (transduce identity (insights cols) [["2017" 700]])
first
:last-value))
;; Here we just make sure we don't blow up on empty input
(expect
nil
(-> (transduce identity (insights cols) [])
first
:last-value))
(expect
nil
(-> (transduce identity (insights cols) [[nil nil]])
first
:last-value))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment