#clojure log - Aug 19 2012

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:01 Frozenlock: uvtc: do you have the link to the blog post?

0:06 Yay! http://blog.fogus.me/2012/03/27/compiling-clojure-to-javascript-pt-3-the-himera-model/

0:22 Using the browser repl might be more pratical than inferior-lisp, as it doesn't have completion and docs anyway.

0:39 emezeske: REPL - E = cat

0:40 eggsby: hah, hadn't thought of that emezeske

0:40 Frozenlock: I don't get it...

0:43 eggsby: Frozenlock: cat is a process that reads input, prints it out, and loops doing that forever so long as the process runs :p

0:45 Frozenlock: Ohhhh

0:46 I was trying to see the link.. well you know, cat.... meow

0:47 emezeske: ^_^

0:48 Frozenlock: Himera doesn't evaluate in the browser, does it?

0:48 Rather: does it send the data to heroku to be evaluated?

0:49 eggsby: that's my understanding

1:09 muhoo: cljs repl in inferior lisp seems a lot more reliabl than nrepl with piggieback so far

1:10 Frozenlock: ...but still no autocomplete or docs!

1:10 I can't stay like that!

1:11 * Frozenlock runs in circle

3:40 ethanis: hey folks, is there a separate clojurescript irc channel, or is this an appropriate place to ask cljs-related questions?

3:43 antares_: ethanis: cljs is discussed in here

3:44 ethanis: great, anyone have experience specifying externs so advanced compilation works with an existing javascript project?

3:44 I'm writing an application that targets the facebook javascript sdk

3:45 and I'm using leiningen with cljsbuild

3:45 I've specified an externs file that I made by hand

3:45 it looks like this: https://gist.github.com/3393401

3:46 lein cljsbuild is definitely hitting this file

3:46 but when it does so, during the compilation process, it emits a series of warnings in vein:

3:46 WARNING - accessing name FB in externs has no effect

3:46 FB = {};

3:46 ^

3:46 WARNING - name FB is not undefined in the externs.

3:46 FB.api = function(location, callback){};

3:46 and so on

3:47 and not only does it emit warnings, but it ends up renaming the FB variable to a gibberish string, making the outputted script dysfunctional

3:47 SO, with all of that background in mind, my question is:

3:48 how can I wrangle my externs file so that cljsbuild/the closure compiler will make proper use of it and avoid renaming the global FB object?

3:49 I'm trying to use https://github.com/ibdknox/jayq/blob/master/resources/externs/jquery.js as a model

3:49 but jquery only has *functions* defined in the global namespace, whereas FB is an *object*

3:50 I've found a similar issue discussed in the clojure google group: https://groups.google.com/forum/?fromgroups#!topic/clojure/VN6YzyJIg2s%5B1-25%5D

3:51 but no clear solution emerged

3:57 michaelr`: hello

3:58 amalloy: ethanis: you probably want to ask closure folks, not clojure folks. like, maybe someone here knows the answer, but probably everyone there does

3:58 ethanis: alright, that's a very good point, thanks amalloy

4:05 for posterity: http://code.google.com/p/closure-compiler/source/browse/trunk/contrib/externs/facebook_javascript_sdk.js?r=1000

4:05 hooray

4:30 ebaxt: in emacs, is there a way to ident only the 'defn' you are editing?

4:34 amalloy: M-q if you have paredit on

4:37 ebaxt: amalloy: thanks :)

4:37 amalloy: ebaxt: in future, you can try C-h a indent RET

4:39 ebaxt: amalloy: future?

4:39 amalloy: ebaxt: next time you're looking for a function

4:39 ebaxt: amalloy: nice :)

4:43 michaelr`: clojure.tools.trace is goooood..

4:44 antifuchs: amalloy: note that C-h a only searches for interactive functions; M-x apropos RET for non-interactive stuff/variables, too (:

4:45 amalloy: antifuchs: is that different from C-u C-h a?

4:46 antifuchs: amalloy: oho, I didn't know about that!

4:46 I don't think that was in emacs 21 back when I learned (:

4:46 so thanks (:

4:50 michaelr`: how do you guys usually debug hideous problems somewhere deep down the call graph? do you also use clojure.tools.trace?

4:51 _ulises: michaelr`: I use ghetto debugging techniques which I'm not too proud of, i.e. bunch of println all over the shop

4:53 michaelr`: _ulises: that was also my method, but right now i'm using libraries not written by me which also use other libraries.. etc etc

4:54 and it's not really clear what calls what since it's written in cps style

4:54 _ulises: michaelr`: indeed the approach doesn't scale; I think I kinda got ok at reading stacktraces so I generally can figure out what's happening from reading those

4:54 oh

4:55 michaelr`: anyways, i think i've found the problem I've been banging my head at for quiete some time now

4:55 _ulises: michaelr`: excellent then

4:55 michaelr`: it took 1/2 hour using the tracing tool

4:55 super cool

4:56 _ulises: michaelr`: by the way, there's a debugger for clojure I used some time ago, by george hajad (probably misspelt) which was rather nice when I tried it

4:56 michaelr`: i never managed to make it work.. some day maybe i'll try again :)

4:57 _ulises: interesting

4:57 it was fairly painless for me to set it up

4:57 I just never got into the flow of using it I guess

5:57 firesofmay: Hi, how do you create a webdriver instance for a particular version/platform using clj-webdriver?

7:02 Raynes: It's 6AM. Do you know where your Clojure is?

7:07 cmelbye: Hi! Are there any clojure web frameworks that make it easy to use straight up HTML views instead of having to write HTML using a clojure DSL?

7:13 antares_: cmelbye: Noir and Compojure can use Mustache templates, for example, or anything you want

7:13 Hiccup is not a requirement

7:13 I use Noir with Stencil (https://github.com/davidsantiago/stencil)

7:23 cmelbye: antares_, oh that looks awesome! so if you don't mind sharing, how do you structure your project's directories? like where would you put mustache template files

7:26 antares_: cmelbye: I keep them in src/resources/templates

7:26 it can be anything on the classpath under a well named directory, basically

7:26 I put src/resources on classpath via project.clj

7:27 then during deployment, if you package everything in a single "far jar", templates will be included as well

7:34 cmelbye: antares_, ah okay, awesome. I think I've tried stencil, but I got a little confused on how to load templates. how would you load and render a template in src/resources/templates?

7:35 antares_: cmelbye: https://gist.github.com/05b81f8ab565f95df001

7:37 cmelbye: antares_, so that file would be src/resources/templates/events/tagged.mustache? why is it just "templates/..." and not "resources/templates/..."? (sorry for the questions, I'm still new to this haha)

7:38 antares_: cmelbye: because it has to be a relative path on the classpath

7:39 and I put src/resources to classpath with :resource-paths ["src/resources"] (lein2)

7:40 cmelbye: ohhh okay, that makes sense! thank you so much, I'm going to give mustache/stencil a try - hiccup drove me crazy :)

7:40 raek: note that "resources/" is on the classpath by default

7:42 cmelbye: raek, like without "src/"? just a "resources" directory in the root?

7:42 antares_: cmelbye: yes, in the same directory where project.clj is

7:43 cmelbye: ah, interesting

7:51 nz-: cmelbye: there is also enlive

10:12 jballanc: how would one go about conditionally require'ing a ns only if it exists?

10:19 gfredericks: oh I saw that the other day

10:19 I think clj-http does that with cheshire

10:20 https://github.com/dakrone/clj-http/blob/master/src/clj_http/client.clj#L18

10:29 jballanc: heh...ok, try/catch as I feared :(

10:29 (I was hoping there was a way to check the classpath without having to catch the load error)

11:00 llasram: jballanc: You actually *could* do it that way, using clojure.java.io/resource (or the backing implementation functions), but I think catching the load exception is the more typical cross-language pattern

11:14 casion: ,(reduce * (range 5))

11:14 clojurebot: 0

11:14 casion: why doesnt that work?

11:14 Chousuke: because range starts from 0

11:14 casion: ok

11:14 thank you

11:15 simple enough to fix :)

11:15 gfredericks: ,(reduce * (range 1 5))

11:15 clojurebot: 24

11:15 casion: yeah

11:16 wmealing_1: http://hastebin.com/nopuhemuca.lisp <-- you'd expect this to run for a long time.. right ?

11:16 i mean while true

11:16 apparently it stops before forever .. see http://hastebin.com/kijolineni.xml

11:18 can someone tell me what i'm doing wrong

11:19 gfredericks: wmealing_1: daemon threads don't keep the jvm running right?

11:19 azm: table

11:19 uses clojure

11:19 so I joined

11:19 gfredericks: if you don't set it as a daemon will it run?

11:19 wmealing_1: testing now

11:19 gfredericks: wmealing_1: it sounds like setDaemon(true) is the exact opposite of what you want

11:20 wmealing_1: you're right

11:20 it keeps running

11:20 either I completely misunderstand what a daemon is

11:20 or someone else got it wrong

11:22 * wmealing_1 goes reading

11:25 Kvaks: I'm doing a fresh installation of clojure. I've got the lein script, run it's self-install procedure and I've installed emacs24. Question: Which emacs-packages (from the new emacs package system) do I need?

11:28 hyPiRion: Kvaks: have you added the marmalade-repo?

11:29 Kvaks: Yes, I have (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/&quot;))

11:29 in my .emacs

11:31 hyPiRion: https://github.com/ftravers/PublicDocumentation/blob/master/clojure-development-setup.md

11:32 Kvaks: Thanks.

13:03 sayyestolife: Let's say I have a structure like this ({:name "foo" :value 1} {:name "baz" :value 2} {:name "foo" :value 3}) and I'd like to convert into something like ({:name "foo" :value 3} {:name ""baz" :value 2}). That is, I'd like to remove those who has a certain key (:name in this case) so that it only exists one per unique name.

13:04 _ulises: sayyestolife: see merge-with

13:04 ,(doc merge-with)

13:04 clojurebot: "([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."

13:07 sayyestolife: But, I don't want to merge them all together, I'd still like to have them in separate maps in a list/vector

13:08 _ulises: Isn't that one for merging together into a single hash-map?

13:08 gfredericks: sayyestolife: so you want to prefer the later ones when the :value matches?

13:09 _ulises: sayyestolife: indeed, that's for merging, that's what I thought you wanted

13:09 sayyestolife: oh, I just re-read your question, I thought you wanted merging with +

13:09 sayyestolife: gfredericks: the :value doesn't matter, I want to have so that I don't have any duplicates of :name

13:10 gfredericks: sayyestolife: oh right sorry; but prefering the last one with any given name?

13:10 sayyestolife: yea, gfredericks I think so¨

13:11 gfredericks: ,((fn [recs] (vals (reduce #(assoc %1 (:name %2) %2) {} recs))) ({:name "foo" :value 1}

13:11 {:name "baz" :value 2} {:name "foo" :value 3}))

13:11 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

13:11 gfredericks: ,((fn [recs] (vals (reduce #(assoc %1 (:name %2) %2) {} recs))) ({:name "foo" :value 1} {:name "baz" :value 2} {:name "foo" :value 3}))

13:11 clojurebot: ([:value 3])

13:11 gfredericks: well that's sure not what I meant

13:11 ah right

13:12 ,((fn [recs] (vals (reduce #(assoc %1 (:name %2) %2) {} recs))) [{:name "foo" :value 1} {:name "baz" :value 2} {:name "foo" :value 3}])

13:12 clojurebot: ({:name "baz", :value 2} {:name "foo", :value 3})

13:12 gfredericks: so that one will return the results in an undefined order, so as long as you're okay with that

13:12 llasram: Huh. You could write a lazy `distinct-key` which would only emit the first and be v generic, but I think doing the last with a particular key-value is like a highly-specific-business-rule sort of thing

13:12 sayyestolife: gfredericks: thanks!

13:13 gfredericks: np

13:24 casion: ,(mod -4 3)

13:24 clojurebot: 2

13:24 casion: that… that is confusing

13:24 llasram: ,(rem -4 3)

13:24 clojurebot: -1

13:25 casion: what's the point of having mod work like that?

13:25 danlarkin: (doc mod)

13:25 clojurebot: "([num div]); Modulus of num and div. Truncates toward negative infinity."

13:25 danlarkin: (doc rem)

13:25 clojurebot: "([num div]); remainder of dividing numerator by denominator."

13:26 Peregrine: truncates towards 0 would seem more logical but it's current behaviour is documented

13:28 llasram: &(map #(mod % 3) (range -3 4))

13:28 lazybot: ⇒ (0 1 2 0 1 2 0)

13:28 llasram: casion: That's why

13:29 &(map #(rem % 3) (range -3 4))

13:29 lazybot: ⇒ (0 -2 -1 0 1 2 0)

13:29 casion: that does not make sense to me

13:30 llasram: *shrug* It matches the formal definition of modulus

13:31 gfredericks: there are two ways you might want it to work and there is a function for each

13:31 Peregrine: Which formal definition of the modulus operator.

13:31 I've never seen a formal definition and there are 2 logical ways truncated towards 0 or truncated towards negative infinity

13:31 gfredericks: just making one up on the spot, (mod x n) returns a number in (range n) such that (- x (mod x n)) is divisible by n

13:31 casion: Peregrine: ditto

13:32 gfredericks: well I guess the other one works for that too

13:32 casion: -4 % 3 gives -1 in C, which I'd expect

13:32 and it seems most languages give -1

13:32 Peregrine: As far as I recall most programming languages I have used truncate towards 0.

13:32 gfredericks: no wait it doesn't

13:32 in modular arithmetic you want things to be in (range n)

13:33 so returning a negative wouldn't make sense

13:33 Peregrine: It's an arbitrary decision though whether you should truncate towards 0 or negative infinity

13:35 llasram: Exactly, gfredericks. In modular arithmetic, -1 is congruent to 2. So that's what `mod` returs

13:35 er, -1 congruent to 2 (mod 3), that is

13:35 gfredericks: if you're not doing modular arithmetic, then you might want some other behavior; like never returning a larger number

13:35 Peregrine: Yes, I know wikipedia and all but I don't want to search for actual references http://en.wikipedia.org/wiki/Modulo_operation

13:36 The method clojure uses should more accurately be described as floored division not truncated division

13:38 err wait clojure uses the euclidian definition.

13:39 It's easy enough to define a modulo operation that behaves where it truncates towards 0 but the answer is there are lots of definitions of modulo and any of them are valid.

13:40 If i didn't have to search boxes for it I would look to see what Knuth says.

13:42 gfredericks: he says "Who are you and how did you get into my house?"

13:42 llasram: Huh. The Wikipedia Knuth citation on the page you linked to doesn't include a page or even volume number!

13:43 Peregrine: gfredericks, likely so but luckily he's written about it apparently although it's a horrible citation on wikipedia

13:45 Ahh indeed Knuth uses floored divisio. According to Knuth (mod -4 3) is -2

13:48 Err no (mod -4 3) is 2 according to Knuth. The result has the sign of the divisor.

13:48 gfredericks: I guess (range n) doesn't mean much when n is negative

13:48 Peregrine: ,(mod -4 -3)

13:48 clojurebot: -1

13:48 Peregrine: ,(mod 4 -3)

13:48 clojurebot: -2

13:49 llasram: &(map #(mod % -3) (range -3 4))

13:49 lazybot: ⇒ (0 -2 -1 0 -2 -1 0)

13:57 Frozenlock: Is there a cljs wrapper for http://code.google.com/p/flot/ ? (I don't think so... but better to ask anyway)

14:05 casion: ,(map #(mod % 12) (range -40 40 12))

14:05 clojurebot: (8 8 8 8 8 ...)

14:05 casion: ok, that makes sense then

14:19 Frozenlock: Nvm that, I'd rather have this one http://www.filamentgroup.com/examples/jqueryui-visualize/ It uses the data from an html table, so it's still available for those with screen readers!

14:43 TimMc: Peregrine: All I know is that I'm happy that Clojure chose the modulo they did.

14:47 &(range -5)

14:47 lazybot: ⇒ ()

14:47 jballanc: has anyone come up with a way to deal with "fold" if you don't have reducers?

14:47 i.e. write something compatible with 1.4 and 1.5

14:47 so far, this is what I have: https://gist.github.com/3396985

14:54 Peregrine: TimMc, it's easy enough to write a round towards 0 modulo with what clojure has so it's fine the way it is

15:00 TimMc: Peregrine: rem doesn't do what you want?

15:01 Peregrine: I wasn't the original person confused about modulo so I haven't explored if rem does what I would expect with regards to modulo truncating towards zero.

15:02 I'm just saying if I needed modulo truncating towards zero instead of towards negative infinity I can see an easy way to write it with the existing mod

15:04 And that claiming that clojures mod follows the formal definition of modulus is odd since I'm unaware of a formal definition and I've found at least 3 formal definitions of the modulus operator.

15:06 jasonjckn: What clojure debugger options do I have which have step in, step out, step over, etc, type debugging. I'm going to try jswat right now. That's the only one i'm aware of.

15:08 Peregrine: Interestingly according to wikipedia clojure's mod differs from javas % operator.

15:20 casion: Peregrine: from what I can tell, C/java, clojure/haskell, and python/ruby all handle modulo differently

15:20 which is why I was confused

15:20 from what I understand now, mod in clojure is modular division, not modulo

15:21 % in C/java is euclidian modulo

15:21 and python/ruby have different operators for the different concepts

15:25 jasonjckn: is anyone working on a debugger for clojure?

15:25 jswat is really bad but all the pieces are there

15:27 xeqi: jasonjckn: hugod has been working on https://github.com/pallet/ritz

15:27 theres also cdt

16:04 jasonjckn: xeqi: intellij actually has a great debugger, playing with it now

16:04 ritz looks amazing too, i'd rather stay in emacs

16:14 bosie: using leiningen, shouldn't putting this http://pastebin.com/90ccMpRh in my ~/.lein/profiles.clj file and then doing "lein repl" give me access to the plugin?

16:34 Frozenlock: I'm a little confused.. how can I add an external JS library? (not from google closure)

16:36 eggsby: Frozenlock: couldn't you just include it and use it's globals via js/jQuery or w/e

16:37 _ulises: Frozenlock: don't have much experience with CLJS but I reckon you have to include it in your html and then access it via js/*

16:37 Frozenlock: what eggsby said

16:38 Frozenlock: So something like that? (ns my-namespace (:require [jquery.flot.js :as flot]))

16:38 With (include-js "path to my js") in my common html wrapper?

16:39 bosie: ok found a way

16:40 http://pastebin.com/7UPVy3X3

16:40 thats the same?

16:44 Frozenlock: goog.require could not find: jquery.flot.js :(

16:46 eggsby: Frozenlock: :require is for things registered as closure models iirc, instead you'd just have the <script src="lib.js"> before your cljs.js file and call it via (.someMethod js/lib my-args) afaik

16:48 s/model/module

17:04 bosie: could someone please tell me how i can get this going: https://github.com/mmcgrana/clj-stacktrace

17:06 llasram: bosie: Easiest way is probably to switch to lein 2.x -- it's integrated into the `lein repl` REPL in 2.x

17:07 bosie: llasram: i am on lein

17:07 llasram: Version 2 or 1?

17:07 bosie: 2

17:07 http://pastebin.com/S0AtTh1L

17:07 llasram: Then you've already got it

17:07 Hmm

17:08 Ok, maybe I'm mistaken and am just sowing confusion. I use SLIME, so don't have direct experience

17:09 Oh, looks like I might have been wrong? Weird. That never happens :-)

17:09 bosie: haha

17:09 llasram: Anyway, doesn't the clj-stacktrace README have a copy-paste example of how to integrate with lein 2 ?

17:10 bosie: llasram: thats what i did

17:10 llasram: i did the first thing for leiningen 2.x https://github.com/mmcgrana/clj-stacktrace#leiningen

17:11 llasram: Hmmm

17:17 xeqi: that dependency map looks weird, not sure if it would work

17:17 Frozenlock: I guessed I should use :foreign-libs in my project.clj... but now `lein cljsbuild auto' just hangs...

17:17 llasram: Huh. I didn't even notice that. It does work, but I agree not for good-seeming reasons

17:18 bosie: xeqi: its straight from the author's github

17:18 xeqi: how should it look/

17:18 ?

17:19 xeqi: [[clj-stacktrace "0.2.4"]]

17:20 bosie: like this: {:user {:plugins [[clj-stacktrace "0.2.4"]]}} ?

17:20 xeqi: no, :plugins is not the same as :dependency

17:20 * :dependencies

17:20 bosie: k

17:21 i added {:user {:dependencies [[clj-stacktrace "0.2.4"]]}}

17:21 same error

17:21 llasram: bosie: What effect do you expect to see?

17:22 Or want to see, I supose

17:22 bosie: llasram: not an error when i do (use 'cli-stacktrace.repl) for starters

17:22 and a formatted stack trace like this: https://github.com/mmcgrana/clj-stacktrace#leiningen

17:22 https://github.com/mmcgrana/clj-stacktrace#clj-stacktrace

17:22 xeqi: do you have the :injections lines as well?

17:23 bosie: xeqi: no, removed them

17:23 added them now

17:24 llasram: It seems not to be working with nrepl... That's the issue. You're getting clojure.repl already `used`d, and the injections aren't having the expected effect

17:24 bosie: llasram: hm

17:25 great

17:28 llasram: lol. comment in nrepl "TODO customizable exception prints"

17:29 bosie: is this normally the way clojure libs are?

17:29 wrongly documented?

17:29 llasram: No

17:29 antifuchs: s/ clojure// (-:

17:29 bosie: antifuchs: coming from ruby i am used to it ;)

17:30 antifuchs: hah, yeah, same

17:30 llasram: Haha. The REPL stuff is undergoing faster-than-normal evolution, and the majority of Clojure users have been using SLIME, which skips much of this stuff

17:30 bosie: llasram: as an ide user i feel alienated anyways :/

17:31 llasram: But now that nrepl.el is getting stable, the Emacs community will probably switch, which should stablize things

17:31 Switch to emacs!

17:31 bosie: llasram: no way, i am a vim user

17:32 llasram: vim is an IDE?

17:32 bosie: llasram: no but intellij is

17:32 llasram: Anyway, I have an apparent solution for you

17:32 bosie: llasram: but if i have to use a non-ide its vim

17:32 Raynes: I've been pretty satisfied with Emacs and evil-mode.

17:33 llasram: In the example :injections form, change switching out clojure.stacktrace/print-cause-trace to clojure.main/repl-caught

17:33 Then you'll get a pretty stack trace on exceptions

17:33 For certain values of "pretty" :-)

17:34 Frozenlock: Are libraries automatically available when doing `<script type="text/javascript" src="...'?

17:35 * Frozenlock is about to throw his computer out the window

17:35 bosie: llasram: no idea what you mean so i figure i have to learn more clojure before i get pretty ;)

17:36 Raynes: how does evil-mode handle the keyboard shortcuts?

17:37 Raynes: or do you have to rebind everything manually?

17:38 Raynes: evil-mode doesn't replace Emacs's keybindings.

17:38 It adds Vim stuff on top of it all.

17:38 You still need to learn some Emacs.

17:38 bosie: Raynes: yes but vim stuff is also keybindings, so you never leave homerow

17:38 llasram: bosie: Try this: https://www.refheap.com/paste/4492

17:38 Raynes: Can't help you there. I don't understand the fascination with homerow everyone has.

17:39 llasram: I use a chording keyboard that only has a home row

17:39 (jk)

17:39 bosie: Raynes: efficiency, speed, prevents CTS

17:39 Raynes: Oh thanks, I understand now. ;)

17:40 bosie: Raynes: i wasn't joking, at least for me its the case

17:40 llasram: right

17:40 Raynes: Okay.

17:40 bosie: llasram: starting repl with lein repl

17:41 llasram: first thing i do ("f") doesn't give me a full stacktrace

17:41 llasram: Really?

17:41 bosie: yes

17:41 gives me one line

17:41 llasram: Does for me :-()

17:41 bosie: meh

17:41 llasram: :-( even

17:41 Well, I tried

17:41 bosie: exactly. thank you very much

17:41 llasram: What version of Clojure in the projcet, OOC?

17:42 bosie: project?

17:42 clojurebot: project euler is http://ProjectEuler.net

17:42 bosie: llasram: no project

17:42 arrdem: can I get some help with `lein uberjar`? I'm trying to actually package and deploy a project for the first time and when I run the generated jar I get an error that the .core class is not found. ideas?

17:43 llasram: bosie: Oh, wow. This looks like a lein bug, but I'm not seeing the :user profile applied if I launch lein repl outside of a project

17:43 Try doing it w/in a project directory

17:43 bosie: sec

17:43 llasram: (most people seem to keep a scratch project sitting around for this sort of thing)

17:45 bosie: llasram: started

17:45 OMG

17:45 llasram high five

17:45 llasram: yay!

17:45 My work here is done :-)

17:45 bosie: very pretty indeed

17:45 thank you very much indeed

17:48 dnolen: Frozenlock: I take it you haven't done much JS :) the order of script tags matters - but yes.

17:49 Frozenlock: dnolen: I haven't done any at all, which is why I find it so aggravating... EVERY article/blog post about cljs assumes the user knows about JS :(

17:50 dnolen: Frozenlock: I imagine that will always be the case. Perhaps higher levels frameworks / tools can hide more of that one day.

17:51 Frozenlock: O-M-G I just did it

17:52 (used the library I wanted, that is)

17:52 Now, I must never close my REPL again...

18:03 How does the js data translate to cljs? The tutorial I'm following says `{ label: "Foo", data: [ [10, 1], [17, -14], [30, 5] ] }'... this would be {:label "Foo" :data [[10 1] [17 -14] [30 5]]} ?

18:08 arrdem: \exit

18:18 gfredericks: Frozenlock: if you're interoping with something JSy, then those are not interchangeable no

18:19 in the same way that if you want to use a jave method that wants a j.u.HashMap you cannot give it {}

18:19 Frozenlock: I see..

18:19 I've found this http://stackoverflow.com/questions/10157447/how-do-i-create-a-json-in-clojurescript?rq=1, is there an equivalent function now in cljs.core?

18:19 * gfredericks doesn't know

18:20 Raynes: gfredericks doesn't know anything.

18:25 * Frozenlock stumbles uppon Raphaël. Is amazed.

18:26 gfredericks: Frozenlock: I'm using Raphael to good effect in cljs

18:27 Frozenlock: Yeah this looks very nice, especially the fact that it's using svg!

18:28 Do you have any online stuff?

18:29 gfredericks: I suppose not with that combination

18:29 I might put it online in a month or so

18:36 Frozenlock: Except apogee, is there other cljs svg libraries?

18:48 lynaghk: Frozenlock: most of the data visualization stuff we do is SVG in cljs via the C2 library

18:52 nkoza2: the algorithmic complexity for (concat mylist '(3)) is O(n) or O(1) ? Do the lists keep a reference to his tail?

18:53 gfredericks: ultimately O(n), but it returns a lazy seq

18:54 so it'll be amortized over the length of your seq

18:54 nkoza2: can you append a element to the end of a list in O(1) time?

18:54 gfredericks: not a list, no

18:54 a vector yes

19:04 amalloy: and a lazy-seq in O(1) time, sort of

19:04 Frozenlock: lynaghk: thanks!

19:05 amalloy: nkoza2: the point is that laziness makes algorithmic analysis more complicated. concat returns in constant time, but adds a small amount of overhead to each access of the first list, so in that sense it's O(n)

19:06 nkoza2: concat is wrapping the original list in a lazy-seq structure that knows when to jump to the appended element?

19:06 amalloy: interestingly, unless i'm mistaken, the relevant N there is the size of the first collection, not the second, so (concat [1] coll) is O(1) in every interesting sense, whereas (into [1] coll) takes linear time in the size of coll

19:07 nkoza2: yes

19:07 nkoza2: ahh, I see, thanks

19:08 because this the [insert-at-the-front + reverse when all items inserted] idiom seen in other languages (as Erlang) is no so common in Clojure, right?

19:09 gfredericks: well clojure has other data structures

19:09 so if you want to build something up starting at the left, vectors are great for that

19:10 amalloy: gfredericks: yes, but i'd say lazy sequences are a more relevant reason

19:10 like, you can take a cons+reverse algorithm and make it a vector+conj alforithm, but lazy sequences make more sense since we deal with so many infinite sequences

19:10 gfredericks: well you wouldn't want to use concat to build something up from the left

19:10 that would be O(n^2)

19:10 if you use it for each item

19:11 amalloy: and also blow the stack

19:11 gfredericks: that sounds familiar

19:11 amalloy: &(first (reduce concat (range 10000) []))

19:11 lazybot: ⇒ 0

19:11 amalloy: errrr

19:11 &(first (reduce concat [] (range 10000)))

19:11 lazybot: java.lang.StackOverflowError

19:11 gfredericks: &(concat [] 3)

19:11 lazybot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long

19:12 gfredericks: why did that first one return 0?

19:12 amalloy: gfredericks: because it starts with (range 10000) and reduces 0 elements into it

19:12 gfredericks: oh right

19:12 amalloy: (= n (reduce f n []))

19:12 gfredericks: I misorderead the args

19:12 nkoza2: the reduce order of application is ensured?

19:13 gfredericks: yep

19:13 amalloy: reduce is foldl

19:17 nkoza2: ok, thanks

19:36 Frozenlo`: lynaghk: My brain just melted because of your cljx

19:41 splunk: mutt

19:41 oops

19:43 qmx|brb: does the amotoen creator hangs around here?

20:04 lynaghk: Frozenlo`: yeah, I have mixed feelings about that project. It does what I need it to, though.

22:20 kendru: I'm coming to Clojure from a background of primarily PHP and Ruby (no Java), and I was wondering if it would be worthwhile trying to learn the Java libraries first or to just jump right into Clojure

22:20 amalloy: kendru: you should probably stay away from java until you find a need for it

22:21 gfredericks: not to mention "the java libraries" ... well there are a lot of them.

22:21 and they're not annotated with "useful for clojure" and "not useful for clojure"

22:21 amalloy: some stuff leaks through for sure, but you can do a lot with very little knowledge of java. the most-common functions on java.lang.String are probably the first you'll need java for

22:22 kendru: amalloy: Thanks, the String functions are the ones that I have seen most often in sample code.

22:22 gfredericks: man I almost never use those

22:22 probably because I forget they are there

22:23 kendru: it's good to know that clojure is mature enough that i won't be needing java interop at every turn.

22:25 jkkramer: amalloy: just sent you (flatland) a fix for ordered-map FYI

22:28 amalloy: jkkramer: thanks for the notice. i apparently don't have that repo Watched since github's notification changes

22:28 was it throwing an exception? the code you replaced looks like it wouldn't work at all

22:29 jkkramer: yeah it was

22:30 ClassCastException for the erroneous type hint

22:31 amalloy: jkkramer: 1.3.2 is on clojars

22:33 jkkramer: amalloy: awesome thanks. everything working as expected now

22:34 amalloy: that's good, cause i didn't run any tests. took travis's word for it (thanks antares & Raynes!)

22:35 jkkramer: heh

23:43 Gnosis-: I added -Xmx128m to LEIN_JAVA_CMD in the lein shell script. Is this a bad idea?

23:56 amalloy: i'm surprised so many people want ordered maps. i wrote ordered just to demonstrate clojure has matured enough to make it possible without writing any java; i don't see them as being that useful very often

Logging service provided by n01se.net