Skip to content

concat always returns a vector #474

Open

Description

@jmglov

Pixie's concat always returns a vector, whereas in Clojure, it returns a lazy seq:

Pixie:

(concat (take 2 (range 1)) (take 1 (repeat nil)))
;;=> [0 nil]

Clojure:

(concat (take 2 (range 1)) (take 1 (repeat nil)))
;;=> (0 nil)
(realized? (concat (take 2 (range 1)) (take 1 (repeat nil))))
;;=> false

I think the Clojure behaviour is more desirable here.

Activity

  1. jmglov commented on Dec 15, 2015

    @jmglov
    ContributorAuthor

    @thomasmulvaney @mpenet What do you guys think about this one?

  2. thomasmulvaney commented on Jan 7, 2016

    @thomasmulvaney
    Member

    I agree. One would expect concat to behave lazily.

  3. mpenet commented on Jan 7, 2016

    @mpenet
    Contributor

    +1 for lazy concat, just for clojure compatibility's sake.

  4. jmglov commented on Jan 7, 2016

    @jmglov
    ContributorAuthor

    This might be a good one for me to take a swing at into order to get familiar with Pixie's sequences implementation. I'll see what I can do. :)

  5. brian-dawn commented on Feb 25, 2016

    @brian-dawn

    @jmglov Were you still planning on fixing this? If not I would be happy to work on it.

    Also I noticed something interesting with regards to performance, anyone have any idea why this is?

    user => (time (take 2 (concat [3] (range))))
    "Elapsed time: 24.371005 ms"
    (3 0)
    user => (time (take 2 (lazy-seq (concat [3] (range)))))
    "Elapsed time: 0.004442 ms"
    (3 0)

    I guess I would expect these to be fairly similar from a performance perspective.

  6. jmglov commented on Feb 26, 2016

    @jmglov
    ContributorAuthor

    @brian-dawn I've gotten really busy at work with non-Pixie stuff, so please feel free to run with it.

    As for your performance question, I'm really not sure.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions