Fork me on GitHub
#beginners
<
2015-11-29
>
seancorfield00:11:43

Oh, I fixed my first "simple and wrong" attempt by adding a pair of [ ]bangs head against wall

markmandel00:11:16

I'm being ropped into moving furniture around the house 😉

roelof08:11:04

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

roelof08:11:21

on this one : (= ( '((1 2) 3 [4 [5 6]])) '(1 2 3 4 5 6))

roelof08:11:35

so for me back to the drawing table

roelof09:11:04

I think my next try will be a recursive one

cjmurphy09:11:08

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...

roelof09:11:23

for me a good learning experience

roelof10:11:30

@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

nando11:11:52

@markmandel: Yes, still stuck in a sense, but if I get too stuck on a 4clojure problem, I go do something else for awhile.

nando12:11:30

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

nando12:11:55

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

nando12:11:27

Is it possible to use named parameters in java.jdbc?

nando12:11:52

@roelof - I also tried mapcat variations on the flatten koan and ran into the same error that you did.

roelof13:11:57

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 ???

seancorfield20:11:04

@nando: no, only positional parameters.

seancorfield20:11:05

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).

roelof20:11:22

anyone a tip for me ?

seancorfield20:11:38

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).

seancorfield20:11:28

But it needs to be recursive to handle arbitrary nesting depth.

nando20:11:14

Ok, thanks for the clarification Sean.

roelof20:11:34

@seancorfield: so mapcat <something> can work, if its can work , can you give me a tip what something can be

seancorfield21:11:30

If you mapcat over a sequence you need to change anything that isn't a sequence to a sequence of one element.

seancorfield21:11:04

Otherwise you're mapcating your own function over the sequence.

seancorfield21:11:49

The earlier mapcat identity suggestion was headed in the right direction - for non-nested sequences.

roelof21:11:46

@seancorfield: so somehow I have to split a seq in the different parts ?

seancorfield21:11:15

No, just mapcat over it.

seancorfield21:11:41

The only logic is checking whether you have sequence or not.

seancorfield21:11:53

It's a really weird puzzle.

roelof21:11:59

that I can check with seq?

roelof21:11:33

yes, I know it's a wierd puzzle. This one costs me more then a lot of puzzles before.

roelof21:11:49

That one I could solve in less then 1 - 2 days

seancorfield21:11:30

I got stuck because my first guess was really close but I got that conversion exception and couldn't figure out why for ages.

seancorfield21:11:36

So it's if seq? s then mapcat else [s] as an outline

seancorfield21:11:20

The trick is figuring out the mapcat call (which is "simpler" than you might think).

markmandel21:11:54

@seancorfield sound like what I had in mind 😄

markmandel21:11:49

Although I was thinking of doing a recursive head / rest, but this looks to be a better simplification

roelof21:11:32

@seancorfield thanks, I will try it tomorrow.it's late now time to slee

revivek22:11:26

Wrote my first bit of code in Clojure—a 50 LOC scraper—would love feedback on it simple_smile x-posted in #code-review Code: https://gist.github.com/revivek/d6559b3fd5b9f661e095 Output (pprinted): https://gist.github.com/revivek/2f61bb8a1fe3311377ea