【发布时间】:2018-12-06 12:47:47
【问题描述】:
我有一个非常实际的问题,即在图案中生成等离子切割线。见附图
我觉得这将是纯函数式编程技术的一个很好的演示,如果有人愿意分享使用 ramda 或类似库的解决方案,因为我正在尝试学习以 FP 方式解决问题,但老实说,我什至没有知道从哪里开始
// arrays a and b will always have same size, but number of points vary from cut to cut
let a = ['A0', 'A1', 'A2', 'A3', 'A4', 'A5']
let b = ['B0','B1', 'B2', 'B3', 'B4', 'B5']
// need to make array c combining the two arrays in the following pattern
c = ['A0', 'A1', 'B1', 'B2', 'A2', 'A3','B3', 'B4', 'A4', 'A5' ...]
【问题讨论】:
-
开始:
zipWith(concat, chunksOf(2, lineA), chunksOf(2, tail(lineB)))
标签: functional-programming ramda.js enumerable