Fork me on GitHub
#clojure
<
2017-02-12
>
abhiroop00:02:23

Clojure folks here, you might enjoy this blog post I wrote here on Finger Trees: https://abhiroop.github.io/Finger-Trees/ Although written in Haskell, but should be very easy to follow. In case you are not aware @chouser wrote an implementation of the same in Clojure.

danielsz01:02:17

@abhiroop Awesome work. Kudos to you. Would you care to comment on the differences with hitchhiker trees, which have recently also been implemented in Clojure (and which also sound awesome), https://github.com/datacrypt-project/hitchhiker-tree

gowder06:02:49

hey folks -- does anyone know why shelling out using clojure.java.shell might add a ton of execution time? I'm using Apple's textutil inside some clj in order to convert a rtf file to html, and then do some processing to the html inside my own code. But shelling out to textutil massively increases the execution time, even in an uberjar. And this is so even though running the same textutil command straight from the commandline is instant. Even this minimal test version exhibits the same behavior:

(ns test-shell.core
  (:require [clojure.java.shell :refer [sh]])
  (:gen-class))

(defn string-from-rtf [filename]
  (:out (sh "textutil" "-convert" "html" filename "-stdout")))

(defn -main
  [filename]
  (spit "foo.html" (string-from-rtf filename)))

gowder06:02:07

like, that should not linger for what feels like a full minute. seriously

dergutemoritz06:02:20

@gowder Does it also happen when you use date instead of textutil, for example?

fossifoo07:02:49

@mobileink i guess that still count as a "derivative work" and you would need to adhere to the EPL. then again, if you "steal" 1% of core, it's a question of how much effort that part is really worth, but IANAL

johnnyillinois08:02:40

@mobileink I'd argue. It comes down to what can actually be fought against, and how much money people are willing to put up on both sides.

tianshu11:02:01

How can I transform

[[a1 b1 c1] [a2 b2 c2] [a3 b3 c3]]
to
[[a1 a2 a3] [b1 b2 b3] [c1 c2 c3]]

urix11:02:14

@doglooksgood (apply map (cons vector '[[a1 b1 c1] [a2 b2 c2] [a3 b3 c3]]))

tianshu11:02:44

@urix that's what I want, thx!

tianshu11:02:16

(apply mapv vector '[[a1 b1 c1] [a2 b2 c2] [a3 b3 c3]])

mobileink14:02:44

@fossifoo , @johnnyillinois : I don’t mind the license bit, it’s the copyright bit that isn’t clear to me. Rich Hickey owns his code, but not mine. For reference:

mobileink14:02:53

;   Copyright (c) Rich Hickey. All rights reserved.
;   The use and distribution terms for this software are covered by the
;   Eclipse Public License 1.0 ()
;   which can be found in the file epl-v10.html at the root of this distribution.
;   By using this software in any fashion, you are agreeing to be bound by
;   the terms of this license.
;   You must not remove this notice, or any other, from this software.

mobileink14:02:33

What does “this notice” mean? Surely the licensing terms do not cover copyright?

mobileink14:02:04

I think something like `Portions Copyright (c) Rich Hickey” would be more accurate.

henriklundahl15:02:37

"this notice" is likely the text you just quoted. "this software" is for example the Clojure jar file.

gowder15:02:41

ooooh thanks @mfikes that must be the problem

mfikes15:02:14

gowder: Yes, you can solve it by adding (shutdown-agents) at the end of your script (or when you know your process is otherwise finished).

gowder15:02:47

magical! that indeed was the problem, and I've gone down from a minute to the 10 seconds it should take. thanks so much!

tbaldridge18:02:11

@mobileink look at how the murmur3 code is handled in Clojure. It's under a different copyright/license from the rest of the code.

tbaldridge18:02:55

All that said with the caveat IANAL and I speak for myself (not as a employee of Cognitect)

tbaldridge18:02:17

seems to be some similarities there though.

mobileink19:02:20

thanks, I'll take a look. fwiw i'm not looking to pull a fast one, my code is definitely derived from clojure source and EPLed. Just wondering about copyright, code ownership, and licensing. Haven't thought much about it previously, it prolly does take a lawyer.

tdantas19:02:12

hi guys, I’m running the follow code on my repl

(require '[clojure.core.async :as async])

(def ch (async/chan 1))

(defn caller [channel]
   (async/take! channel (fn [x] (str “some-” x)) true))

(async/put! ch “oli”)
(caller ch)
and according with the take! documentation, if the channel contains value, it will call the function (fn [x] (str “some-” x)) on the calling thread. what I was expecting when I called (caller ch) was the reuslt of (str “some-” x), but I got nil. do you guys know why , any clue ?

hiredman19:02:14

the take! docstring says "Returns nil"

mobileink19:02:47

show of hands: anybody else working on using https://www.polymer-project.org/1.0/ in Clojure? I'm working on a Clojure language extension that supports webcomponents in idiomatic 100% Clojure. There are some tricky design decisions for which I could use some help.

mobileink19:02:39

fyi it will revolutionize web programming. 😉

mobileink19:02:07

I'm thinking specifically about shared styles https://www.polymer-project.org/1.0/docs/devguide/styling#style-modules which are exactly analogous to vars in a namespace. a perfect fit for clojure metaprogramming.

mobileink19:02:27

e.g.:

(:import [styles.foo bar baz])
or similar.

mobileink19:02:59

result being

<link rel="import" href="styles/foo.html">
<style is="custom-style" include="bar"></style>
<style is="custom-style" include="baz"></style>
In this case, bar and baz are "style modules" inside of styles/foo.html.

mobileink20:02:27

the design problem is that we also need to support regular html imports, where

(:import [styles.foo bar])
would mean
<link rel="import" href="styles/foo/bar">
In this case, bar is a file within the styles/foo directory. It's all just namespaces, but with different contexts.

mobileink20:02:49

really more of a design question than a clojure language question, but I don't see any other channel that is obviously more appropriate.

mobileink20:02:38

i suppose responses should probably go to #web .

abhiroop21:02:09

@danielsz Thanks for pointing me towards hitchhiker trees. I was not aware of this project and I just read through its docs. Its ideas of modeling write and insertion as: storage to buffers associated with the B tree nodes and flushing it when necessary, seem somewhat similar(not exactly) to what Rich Hickey talks about datomic in here:https://www.youtube.com/watch?v=V6DKjEbdYos&amp;t=33m45s about an index merging process which seems to do something like a bulk write. Basically being lazy and deferring writes to the actual persistent index until necessary. Correct me if I am wrong, but what I understood is that Hitchhiker trees seem to be solving a pretty specific problem of making functional updates to fractal trees using path copying rather than straight mutation. Fractal trees themselves already seems read and write optimized(better than B+ trees) for database style requirements. Hitchhiker build on top of Fractal trees making it more functional. Finger Trees on the other hand tries to be as generic as possible and answer multiple types of queries(be it search or random access or priority queues) through a common abstraction i.e Monoids. I am pretty sure if we want to optimize a Hitchhiker Tree to answer 2 or 3 specific types of queries we can find Monoidal instances of those types of queries and model reads in Hitchhiker Trees through Finger Trees.

danielsz22:02:02

@abhiroop Thank you for these comments. They were very enlightening. And yes, it is my understanding as well that hitchhiker trees are a refinement of fractal trees in terms of functional data structures. The Strange Loop talk given by the author has been very educational for me. https://www.youtube.com/watch?v=jdn617M3-P4 . I'm mainly on the consumer side, though, quite interested to use an open source implementation of a functional database in production, so the API on top of Redis which the author has made available got me all excited. It's not quite but almost there.