Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behaviour of mori.flatten with JS arrays? #36

Closed
ornamentist opened this issue Aug 21, 2013 · 3 comments
Closed

Behaviour of mori.flatten with JS arrays? #36

ornamentist opened this issue Aug 21, 2013 · 3 comments

Comments

@ornamentist
Copy link

I have this CoffeeScript usage of mori.flatten:

m = require "mori"

console.log m.flatten([1, [2], 3])

The flatten example in the documentation shows it needs its argument to be converted with js_to_clj first--are there any plans to make flatten work with native arrays?

Thanks,

Stu

@swannodette
Copy link
Owner

Hmm, this is an interesting edge case I've never encountered myself. It looks like this behavior has been preserved from Clojure on the JVM. The issue is that we call tree-seq on the argument expecting nodes containing branches to satisfy sequential? which host primitive arrays do not. I wonder if sequential? shouldn't be extended to include host primitive arrays both in ClojureScript and Clojure. I'll ask around.

Thanks for the report.

@swannodette
Copy link
Owner

I think we should just export a version of flatten than can handle arrays.

@swannodette
Copy link
Owner

fixed, http://github.com/swannodette/mori/commit/7d21f1fc8b54a8db3ffe07be2187b72fb622d649

mori.into_array(mori.flatten([1, [2], 3]));

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

No branches or pull requests

2 participants