我已经开始学习 Haskell,但我无法理解列表列表的笛卡尔积如何工作
这是假定的代码
cprod = foldr f [[ ]]
where f xs yss = foldr g [ ] xs
where g x zss = foldr h zss yss
where h ys uss = (x : ys) : uss
我到底没有得到的是我理解的最后一个替换变量名的函数
mycart = foldr f [[]]
where f currentresult listelem = foldr g [] currentresult
where g currentresultonstep currentresultelem = foldr h currentresultelem listelem
where h currentresultelemonstep onelistelem = (currentresultonstep:currentreslteleemonstep):onelistelem
最后一个字符串不应该是这样的吗?
where h currentresultelemonstep onelistelem = (onelistelem:currentresultelemonstep):currentresultonstep
当我们尝试将列表的元素添加到当前结果元素的开头?