Skip to content

Add sequence to stdlib - #509

Merged
thomasmulvaney merged 4 commits into
pixie-lang:masterfrom
x-goose-x:master
Mar 15, 2016
Merged

thomasmulvaney merged 4 commits into
pixie-lang:masterfrom
x-goose-x:master

Conversation

@x-goose-x

Copy link
Copy Markdown

Implement sequence as per #502.

@thomasmulvaney

Copy link
Copy Markdown
Member

Thanks for working on this. Would you be able to add some tests please?

@x-goose-x

Copy link
Copy Markdown
Author

Sure thing. While I was testing I noticed that eductions break the seqable contract in the empty case.

We'd expect:
(seq (eduction (map inc) '[])) to produce nil

but it produces []

Calling seq on the result of the reduce seems to resolve this.

@thomasmulvaney

Copy link
Copy Markdown
Member

I think the problem is that the -seq implementation on Eduction just does a reduce rather than returning a LazySeq. I think the best thing to do would be to fix that by making it lazy.

@x-goose-x

Copy link
Copy Markdown
Author

Agreed, I'll take a crack at it.

On Wed, Mar 9, 2016 at 11:17 AM Thomas Mulvaney notifications@github.com
wrote:

I think the problem is that the -seq implementation on Eduction just does
a reduce rather than returning a LazySeq. I think the best thing to do
would be to fix that by making it lazy.

—
Reply to this email directly or view it on GitHub
#509 (comment).

@x-goose-x

Copy link
Copy Markdown
Author

So I inverted things a little bit by making sequence work lazily and eduction make use of sequence.

There wasn't a clear way to lazily iterate over transducers and as far as I can tell there's no equivalent to the iterators that clojure implements, so I had to write lazy transducer application.

thomasmulvaney added a commit that referenced this pull request Mar 15, 2016
@thomasmulvaney
thomasmulvaney merged commit e621403 into pixie-lang:master Mar 15, 2016
@thomasmulvaney

Copy link
Copy Markdown
Member

Thanks for working on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants