Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// module Data.Traversable
exports.traverseArrayImpl = function(apply) {
return function(map) {
return function(pure) {
return function(consArray) {
return function(f) {
var buildFrom = function(x) {
return function(ys) {
return apply(map(consArray)(f(x)))(ys)
}
}
var identity = function(x) { return x }
var compose(f, g) = function(x) { return f(g(x)) }
var Cont = function Cont(fn) {
this.fn = fn
}
var go = function(g, xs) {
var len = array.length
if (len === 0) {
return acc(pure([]))
} else {
var head = xs[0]
var tail = xs.slice(1)
return new Cont(function() {
return go(compose(g, buildFrom(head)), tail)
})
}
}
return function(array) {
var result = go(identity, array)
while (result instanceof Cont) {
result = result.fn()
}
return result
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.