From d603e0eb8d4c01092e470018fdad2b8a58bff5a5 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Wed, 7 Nov 2018 22:56:26 -0500 Subject: [PATCH] Fix interleave --- src/core/core.janet | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/core.janet b/src/core/core.janet index 1d27692e..aa07d6cc 100644 --- a/src/core/core.janet +++ b/src/core/core.janet @@ -798,10 +798,12 @@ value, one key will be ignored." then the second, etc." [& cols] (def res @[]) - (def len (apply min 0 (mapa length cols))) - (loop [i :range [0 len]] - (loop [c :in col] - (array.push res (get c i)))) + (def ncol (length cols)) + (when (> ncol 0) + (def len (apply min (mapa length cols))) + (loop [i :range [0 len]] + (loop [ci :range [0 ncol]] + (array.push res (get (get cols ci) i))))) res) ###