Next gathering... tomorrow, or in a week's time?

15 views
Skip to first unread message

ja...@ioctl.org

unread,
Apr 22, 2013, 5:15:14 AM4/22/13
to brisfun...@googlegroups.com
That's the question, but as for something functional related to our last
meeting: I couldn't do any better than this

http://www.haskell.org/ghc/docs/latest/html/libraries/base/src/Data-List.html#transpose

Note how the implementation just 'dives into' the nested list structure
(twice, actually, if you count it pulling out both heads and tails of the
sublists). What interested me (more than the issue with using Clojure's
partition over a string) was how the initial attempts to do this tried to
build it out of higher-order functions.

Sometimes, I think you just have to recurse over a structure explicitly
(at least, absent a custom HOF that does the same for you - and I don't
think there's a familiar one that does, in this case) and I think this is
one of those situations.

Cheers,
jan

--
Update your address books: ja...@ioctl.org http://ioctl.org/jan/
That which does not kill us goes straight to our thighs.

Matthew Gilliard

unread,
Apr 22, 2013, 6:28:23 AM4/22/13
to BrisFunctional

The next gathering will be on the 30th.  We don't have a topic yet, so... Roman Numerals?  Or something else?


Now, apparently the "usual" way to transpose a matrix in clojure is:
(defn transpose [m]
  (apply mapv vector m))

Which is succinct I suppose, but not especially obvious.

  mg



--
You received this message because you are subscribed to the Google Groups "BrisFunctional" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brisfunctiona...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Sam Phippen

unread,
Apr 22, 2013, 6:29:35 AM4/22/13
to brisfun...@googlegroups.com
Hi Everyone,

I recently attended the london python dojo, which had a couple of good problems proposed which I'll bring on the night. I also did this kata: http://codekata.pragprog.com/2007/01/kata_two_karate.html which I thought might be a good site for dojostyle.

status203

unread,
Apr 23, 2013, 12:04:19 PM4/23/13
to brisfun...@googlegroups.com, samph...@googlemail.com
On that site I've just found the coding exercise I had to do at interview for my new job!

Arwyn

unread,
Apr 30, 2013, 1:58:55 PM4/30/13
to brisfun...@googlegroups.com
Hi Jan,

I agree; that transpose is a thing of beauty!
My version was mapping head and tail over the list and then reassembling.
The recursive definition is so much cleaner but it did make my eyes cross to begin with.

I think this goes back to that question about readability/verbosity.
We reach for the HOFs because they read more easily but is that just a question of fluency?

Not the case here, but I can't help thinking that if you're coding around a data structure of your own devising then you'll be forced to fall back to a recursive solution unless an abstraction like a functor, monad or zipper is what you need. 

Arwyn
Reply all
Reply to author
Forward
0 new messages