3 ms·
How would you call it? I'm interested in how you'd specify `I` and `O`. `I` is obviously a string, but it seems like `O` needs to be at least three different t
by sillysaurus3 9y ago
How would you call it? I'm interested in how you'd specify `I` and `O`.
`I` is obviously a string, but it seems like `O` needs to be at least three different types:
> (reduce (fn (x y)
(list x y))
(list "a"))
"a"
> (reduce (fn (x y)
(list x y))
(list "a" "b"))
("a" "b")
> (reduce (fn (x y)
(list x y))
(list "a" "b" "c"))
("a" ("b" "c"))
- lilactown 9y ago`O` would be whatever the type of the reducer is, so for `list` in the lisp you're using (is it Clojure? The function params look wrong) has a type signature `(A, B?, ...Z?) -> A | List(A, B, ...Z)`. So the transducer in this case would have the type `List(A, B?, ...Z?) -> A | List(A, B | List(B, ...etc))` It's not three different types, but it is necessarily recursive, which seems tricky.