Skip to content
Advertisement

Don’t know how to create ISeq from: Java.lang.Long

Doing some practice on recursion and map implementation to knock some rust off Clojure. I’m using lists only here so how am I trying to mix seq and non-seqable stuff?

JavaScript

REPL:

JavaScript

Advertisement

Answer

Some errors:

  • replace '(finished-set) with finished-set
  • into adds elements from one collection to another, I think you’re looking for conj (that’s the source of IllegalArgumentException)
  • and if you’ll use conj, you have to use [] as initial finished-set, because conj adds element to beginning of the list, but at the end of the vector

Your function, with minimal changes:

JavaScript

Tests:

JavaScript

You can also write it with only two arguments, using cons:

JavaScript

Note that neither version is lazy, that would require adding lazy-seq.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement