cl-transducers icon indicating copy to clipboard operation
cl-transducers copied to clipboard

Generic `concatenate` and `flatten`

Open fosskers opened this issue 1 year ago • 3 comments

This PR enables concatenate and flatten to accept streams of things that aren't just lists. For now I've expanded this to include vectors, which implicitly supports strings as well.

(transduce #'concatenate
           #'cons (list (cl:vector 1 2 3) (cl:list 4 5 6) (cl:vector 7 8 9)))

yields

(1 2 3 4 5 6 7 8 9)

fosskers avatar Mar 26 '24 23:03 fosskers

Solves my issue, but looks like a game of Whac-A-Mole. It should preferably work on all kinds of inputs, not hardcoded to just list and vector. But it's an improvement :+1: Could a generic method be created for determining if which reducer should be used?

simendsjo avatar Apr 11 '24 12:04 simendsjo

Could a generic method be created for determining if which reducer should be used?

I'll look into this. It occurs to me that many (all?) of the foo-transduce functions may initialise themselves the same way, and then call their inner reducers.

fosskers avatar Apr 11 '24 12:04 fosskers

Let's revisit this after I'm back. Thanks for your patience.

fosskers avatar Apr 14 '24 10:04 fosskers

I need this today, so I'm merging it in.

fosskers avatar Nov 01 '24 23:11 fosskers