From 14171d243b76c845c3a9001aee1a0e9d2056f95e Mon Sep 17 00:00:00 2001 From: Yonaba Date: Sun, 16 Sep 2018 02:18:27 +0000 Subject: [PATCH] Fixed issue with zipping false values --- moses.lua | 2 +- moses_min.lua | 2 +- spec/array_spec.lua | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/moses.lua b/moses.lua index ffdaeb0..eef3534 100644 --- a/moses.lua +++ b/moses.lua @@ -1475,7 +1475,7 @@ function M.zip(...) for i = 1,n do if not _ans[i] then _ans[i] = {} end for k, array in ipairs(args) do - if array[i] then _ans[i][#_ans[i]+1] = array[i] end + if (array[i]~= nil) then _ans[i][#_ans[i]+1] = array[i] end end end return _ans diff --git a/moses_min.lua b/moses_min.lua index e2117cb..feba2ca 100644 --- a/moses_min.lua +++ b/moses_min.lua @@ -258,7 +258,7 @@ function S1wg_DG.zip(...)local cdxFVpZw={...} local Y=S1wg_DG.max(cdxFVpZw,function(BuX1r)return#BuX1r end)local o9Uh={} for Wyf83f2=1,Y do if not o9Uh[Wyf83f2]then o9Uh[Wyf83f2]={}end for P0olj,z in -kyWtqIf0(cdxFVpZw)do if z[Wyf83f2]then +kyWtqIf0(cdxFVpZw)do if(z[Wyf83f2]~=nil)then o9Uh[Wyf83f2][#o9Uh[Wyf83f2]+1]=z[Wyf83f2]end end end;return o9Uh end function S1wg_DG.zipWith(EHCCkt,...)local x={...} local xNWVmS=S1wg_DG.max(x,function(Pkis6H28)return#Pkis6H28 end)local kGWnkgDu={}for tSE=1,xNWVmS do diff --git a/spec/array_spec.lua b/spec/array_spec.lua index 6e618ad..e69e8da 100644 --- a/spec/array_spec.lua +++ b/spec/array_spec.lua @@ -598,6 +598,7 @@ describe('Array functions specs', function() it('zips together values from different arrays sharing the same index', function() local names = {'Bob','Alice','James'}; local ages = {22, 23} assert.is_true(M.isEqual(M.zip(names,ages),{{'Bob',22},{'Alice',23},{'James'}})) + assert.is_true(M.isEqual(M.zip({false},{false}),{{false,false}})) end) end)