This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-29
Channels
- # beginners (41)
- # cider (2)
- # cljs-dev (5)
- # cljsrn (16)
- # clojure (157)
- # clojure-russia (29)
- # clojure-uk (1)
- # clojurescript (164)
- # code-reviews (7)
- # cursive (3)
- # datavis (7)
- # datomic (1)
- # emacs (16)
- # hoplon (2)
- # ldnclj (1)
- # off-topic (4)
- # om (167)
- # other-lisps (10)
- # overtone (8)
- # parinfer (1)
- # re-frame (19)
- # testing (2)
Oh, I fixed my first "simple and wrong" attempt by adding a pair of [
]
… bangs head against wall
I'm being ropped into moving furniture around the house 😉
I did try to solve it with entering mapcat identity but then I see this error message : java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long
Sorry roelof mapcat identity
was a quick stab hint that was only half correct. Just looked at my actual answer and it involves mapcat
and recursion, but no identity
. And I've realised I've gone a bit stale on this stuff myself and need to get back into it...
@cjmurphy: IM thinking now of a solution to look if something is a seq or not. If its it's a seq another "loop" is executed will the end and the numbers are added to a new seq , if not a seq then it can be added to the new seq
@markmandel: Yes, still stuck in a sense, but if I get too stuck on a 4clojure problem, I go do something else for awhile.
I looked at the source code for flatten
to try and get an idea how to go about it. Didn’t help 😉, so I moved on to another problem 4clojure problem and started digging into the documentation for honeysql, java.jdbc, korma, etc
I could of easily missed it, but I don’t see anything about using named parameters in the java.jdbc docs here: http://clojure-doc.org/articles/ecosystem/java_jdbc/using_sql.html
@roelof - I also tried mapcat variations on the flatten koan and ran into the same error that you did.
IM thinking about a solution this way , right out my head https://www.refheap.com/112180 but at the moment I cannot figure out what ,must be the ???
@nando: no, only positional parameters.
It goes direct to JDBC which does it that way by default. I guess I could dig into the docs and see if that would be an easy enhancement (I maintain java.jdbc BTW).
I did it with a recursive function that applied itself via mapcat
to sequences (and I also got the error you saw until I made a very small change to it).
But it needs to be recursive to handle arbitrary nesting depth.
@nando: java.jdbc uses https://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html which only supports positional parameters.
@seancorfield: so mapcat <something> can work, if its can work , can you give me a tip what something can be
If you mapcat
over a sequence you need to change anything that isn't a sequence to a sequence of one element.
Otherwise you're mapcat
ing your own function over the sequence.
The earlier mapcat identity
suggestion was headed in the right direction - for non-nested sequences.
@seancorfield: so somehow I have to split a seq in the different parts ?
No, just mapcat
over it.
The only logic is checking whether you have sequence or not.
It's a really weird puzzle.
I got stuck because my first guess was really close but I got that conversion exception and couldn't figure out why for ages.
So it's if seq? s then mapcat else [s]
as an outline
The trick is figuring out the mapcat
call (which is "simpler" than you might think).
@seancorfield sound like what I had in mind 😄
Although I was thinking of doing a recursive head / rest, but this looks to be a better simplification
@seancorfield thanks, I will try it tomorrow.it's late now time to slee
Wrote my first bit of code in Clojure—a 50 LOC scraper—would love feedback on it x-posted in #code-review Code: https://gist.github.com/revivek/d6559b3fd5b9f661e095 Output (pprinted): https://gist.github.com/revivek/2f61bb8a1fe3311377ea