omori-Sakuya

2023年7月7日

迭代器的练习 (未完成) (道阻且长)

摘要: 第一题 第一题很简单,用闭包实现 function fromto(n,m) local iter = n return function () if iter <= m then iter = iter + 1 return iter-1 end end end for i in fromto(2, 阅读全文

posted @ 2023-07-07 13:55 omori_Sakuya 阅读(6) 评论(0) 推荐(0) 编辑

2023年7月5日

有状态的迭代器

摘要: 实践为先,先写个错误代码 function iter_pro (arr,b) local index = 0 return function () index = index + 1 if arr[index] then return arr[index] end end end a={1,2,3, 阅读全文

posted @ 2023-07-05 11:23 omori_Sakuya 阅读(4) 评论(0) 推荐(0) 编辑

2023年7月4日

学迭代器遇到的一个问题

摘要: 事情是这样的 function iter (arr,index) index = index + 1 if arr[index] then return arr[index],index end end a={1,2,3,5,4} for k,v in iter,{1,2,5,6,5,4},0 do 阅读全文

posted @ 2023-07-04 21:19 omori_Sakuya 阅读(7) 评论(0) 推荐(0) 编辑

2023年7月1日

柯里化和闭包 7.1

摘要: 阅读全文

posted @ 2023-07-01 13:45 omori_Sakuya 阅读(1) 评论(0) 推荐(0) 编辑

第一次写lua 7.1

摘要: 成果 function disk(tx,ty,r) --圆的特征函数 return function(x,y) return (x-tx)^2 + (y-tx)^2 <= r^2 end end function different(a ,b) --差集 return function(x,y) r 阅读全文

posted @ 2023-07-01 11:00 omori_Sakuya 阅读(32) 评论(0) 推荐(0) 编辑

导航