Skip to content

Commit

Permalink
Fixed issue with zipping false values
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonaba committed Sep 16, 2018
1 parent 6c63126 commit 14171d2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion moses.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion moses_min.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/array_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 14171d2

Please sign in to comment.