#clojure log - Nov 06 2015

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

1:57 jonathanj: how do i run my tests with cider?

1:57 M-x cider-test-run-tests doesn't actually seem to have done anything

3:08 in Python there is a count() function that returns an iterator that produces a number one greater than the last: counter = count(); print next(counter); print next(counter) # => 0 1

3:08 i thought this would be straightforward in clojure but apparently not so, do i need to use an atom?

3:09 (i'm writing code where i can replace the function that generates IDs, so i can replace (uuid/v4) with something predictable)

3:09 Kneiva: ,(take 10 (iterate inc))

3:09 clojurebot: #error {\n :cause "Wrong number of args (1) passed to: core/iterate"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: core/iterate"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 32]\n [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eva...

3:09 jonathanj: Kneiva: i think you need a starting value

3:10 Kneiva: but so i'm not quite sure how you turn that into something that when *called* produces the next value

3:10 Kneiva: ,(take 10 (iterate inc 0))

3:10 clojurebot: (0 1 2 3 4 ...)

3:13 jonathanj: i think this is what i want: (defn count [n] (let [counter (atom n)] #(swap! counter inc)))

3:15 Kneiva: ah, of course

3:16 but do you need the state?

3:16 jonathanj: well, i want to be able to pass a value in place of (uuid/v4) and get predictable results

3:16 (constantly 5) would do something but unfortunately then it's a bit hard to verify identity

3:18 i don't know how else to write it

4:13 McDougal: Is clojure mature for web dev or is the community more focused on data processing, machine learning, etc?

4:14 powered: clojurescript is an solid choice for web dev

4:14 lots of libraries are available

4:15 McDougal: Thats for front end, I was thinking ref server side

4:20 the_nonameguy: gfredericks: thx!

4:21 qsys: server side: clojure, surely mature enough, client side: (compiled) clojurescript.

4:24 ring seems to be popular for server side stuff, I like vert.x, which is something very different (and for the latest version, clojure is not supported yet, although it's rather easy to just call clojure from Java)

4:24 McDougal: gsys: Is clojure more performant on vertx?

4:24 Ho about security in clojure web apps?

4:26 the_nonameguy: this is the most common lib for that: https://github.com/cemerick/friend

4:28 qsys: 'more performant' looks somewhat euh... vague. clojure is very performant, so it depends what you're planning. I wouldn't say 'more performant'. I'm just used to using vert.x and never tried ring (and such).

4:29 compojure is another one, by the way: http://www.lispcast.com/what-web-framework-should-i-use

4:30 so well, the usual problem: you have (too many?) choices :p

4:31 McDougal: Thankyou, I'l try out compujure as a starting point

4:31 the_nonameguy: it really depends on what you are trying to achieve

4:32 qsys: or just google web dev clojure :) http://www.luminusweb.net/

4:32 so yeah, what d'you want to do?

4:55 powered: is there a shorter way to do: (map (fn [a b] [a b]) coll-a coll-b) ?

4:58 danneu: powered: (map vector coll-a coll-b)

4:59 powered: thanks that makes sense

5:04 danneu: McDougal: i recommend compojure. simple layer built on top of Ring. check out `lein new compojure hello-world` to generate a small boilerplate to work off of

5:21 mpenet: There are a lot of very performant/flexible ring based adapters, just pick what you like best depending on your needs

5:22 for raw "perf" numbers, they were a few benchmark where some clj adapters were tested and they were doing very good

5:24 ex: netty or undertow based adapters seems to shine in these kind of benchmarks

5:25 Then you can use compojure or whatever framework you want, as long as it's ring compatible.

5:37 owlbird: how to solve module circular dependencies? (app.a/f1) call (app.b/f1), and (app.b/f1) call (app.a/f2) ?

5:38 oddcully: ,(doc declare)

5:38 clojurebot: "([& names]); defs the supplied var names with no bindings, useful for making forward declarations."

5:41 mpenet: wont work accross namespaces with vars that call each other

5:41 oddcully: ah didn't pay attention to that

5:42 mpenet: you need to refactor your code so this doesn't happen

5:42 oddcully: so the answer to that is: fix your code?

5:42 mpenet: yup, it's very often a code smell anyway

5:43 owlbird: By putting all functions in one ns, and name them like a-f1, a-f2, b-f2 ?

5:43 AeroNotix: or a third module with the dependencies of both, if you can

5:43 mpenet: that

5:45 starlord: could someone recommend a good websocket client library? Aleph perhaps?

5:46 mpenet: aleph or jet both have decent jvm based clients

5:46 starlord: great, thanks!

5:49 the_nonameguy: Sente has a client: https://github.com/ptaoussanis/sente

5:51 mpenet: only js based for the client part if I recall tho

6:20 thangappan: I tried to connect clojure web application with mysql database but it's not working..iam new to clojure.Do anyone know this?

6:21 tripleclones: hi, any recommendations on finding freelance devs who work with clojure?

6:24 mavbozo: thangappan, how it didn't work? please provide more context such as used library, error stacktrace

6:24 oddcully: thangappan: "is not working" is a wide field. could put the error/exception on refheap?

6:31 xeqi: tripleclones: If you're looking for someone locally I'd start at a meetup, otherwise post an ad on https://groups.google.com/forum/#!forum/clojure, in here, or at http://clojurians.net in the jobs room.

6:33 tripleclones: xeqi thanks i'll get it together and post here cheers.

6:52 qsys: tripleclones: local or not? I might be interested :p.

7:07 tripleclones: qsys doesnt have to be local

7:11 dnolen: ClojureScript 1.7.170 released! https://groups.google.com/forum/#!msg/clojurescript/AiCARjGT2Mg/J2TdxtHgBAAJ

7:24 gfredericks: dnolen: I just upgraded cljs in the test.check codebase to see if anything would happen -- afaict, the dev build went fine and the test passed, but then the advanced build crashed

7:25 dnolen: gfredericks: you really should trying pre-releases if I mention those :)

7:25 gfredericks: but I'm skeptical at the moment - lots of people ran the pre-releases on non-trivial projects without issue.

7:26 gfredericks: yeah it might just be something about the config in test.check

7:26 or me running on a really old node?

7:26 dnolen: to debug advanced builds

7:26 :pseudo-names true :pretty-print true

7:27 it should be pretty clear what the code is breaking on then.

7:27 gfredericks: also are you using cljsbuild to build?

7:27 gfredericks: yeah

7:27 dnolen: the post above is very clear about needing to use edge tooling for this release

7:27 gfredericks: oh okay sorry

7:27 disregard

7:36 dnolen: yeah it all passes w/ the cljsbuild snapshot

7:37 dnolen: gfredericks: cool

7:50 gfredericks: would love feedback from test.check users about this; am planning on working on it today http://dev.clojure.org/jira/browse/TCHECK-81

8:16 Glenjamin: gfredericks: as (bind) is arguably more complex anyway, i'd be tempted to only sugar (fmap)?

8:16 i dunno whether it's because of the name, but i always do custom generators as an fmap over an existing generator

8:21 gfredericks: Glenjamin: bind is necessary for some things, and it's what you expect as a user from a variant of let

8:21 (because let lets (ha!) you use previous bindings (ha!) which implies bind)

8:44 Glenjamin: Oh, gen/let wouldn't behave like let unless it used bind?

8:45 The examples you provided look great, I guess the whole point is I no longer care if it's bind or fmap

8:50 gfredericks: right -- and that's actually the one thing that feels messy to me from a design perspective, so I care about how useful it would be to real users

8:50 it feels messy because of this, which I guess I should link to in the ticket: https://brehaut.net/blog/2013/duck_wrapping

8:51 oh wait I already did

8:51 wtg past me

9:37 Glenjamin: gfredericks: don't think of it as fmap/bind, think of it as "i want a generator that does this please"

9:38 does fmap generalise to bind? could it just always bind?

9:44 hyPiRion: Glenjamin: Yes. fmap f coll = coll >>= (return . f)

9:48 tomjack: is an om.next query like [{:foo [:bar1]} {:foo [:bar2]}] a user error?

11:36 soleado: I get an error, "contains? not supported on type: clojure.lang.LazySeq" passing the results of `(doall (map #(f %) coll)`. Why is that? I thought `doall` realizes the lazy sequence?

11:38 e.g. `(contains? (doall (map inc [1 2 3])) 1)`

11:39 justin_smith: soleado: contains? isn't supported on lazy-seq, it doesn't do what you probably think it does

11:39 soleado: contains? only works on the keys of associative types, and seqs are not associative

11:39 ,(contains? [:a :b :c] 1)

11:39 clojurebot: true

11:39 justin_smith: because it has an item at index 1

11:39 ,(contains? [:a :b :c] :a)

11:39 clojurebot: false

11:40 justin_smith: because it has no index keyed by :a

11:40 ,(.contains [:a :b :c] :a)

11:40 clojurebot: true

11:40 justin_smith: that's a java method, and actually checks if the collection has an = item, and is probably what you want

11:41 soleado: I understand and I'd be happy with this result:

11:41 (contains? [:a :b :c] :a)

11:41 justin_smith: soleado: :a is not a key on a vector

11:41 so it does not contain it, according to contains?

11:41 contains? does not check contents, only associative keys

11:42 which is why (contains? [:a :b :c] 1) returns true - it has an item at key 1

11:42 soleado: justin_smith: thanks, I understand, but that's not what I'm asking

11:43 justin_smith: what are you asking?

11:43 soleado: my question is why I'm getting a "lazy-seq not supported" error instead of a true/nil

11:43 justin_smith: soleado: lazy-seqs don't have keys

11:43 they are not associative collections

11:43 so contains? can't do anything with them

11:44 I think it would be better if contains? had a different name, like "has-key?"

11:44 but too late for that now

11:44 sdegutis: ,(sort-by (juxt (comp - first) second) [[1 2] [2 1] [3 3] [2 3] [3 2]])

11:44 clojurebot: ([3 2] [3 3] [2 1] [2 3] [1 2])

11:44 sdegutis: Cool.

11:45 oddcully: soleado: doall just realizes the whole thing. but it does not change the type

11:45 at least that is my interpreation of things

11:46 soleado: if you want contains? in the way described, maybe do an (into [] (map...)) instead?

11:49 soleado: So nevermind `contains?` :-) Why is this still a LazySeq? `(doall (map keyword ["a" "b" "c"]))`

11:49 justin_smith: doall doesn't change the type

11:50 snowell: justin_smith: Especially since I am constantly wanting to do (contains? [2 4 6] 2)

11:50 Which will return true in that case, but for entirely the wrong reason

11:51 justin_smith: snowell: (.contains [2] 2), of course

11:51 snowell: ...I'll just be over here

11:51 mavbozo: justin_smith, i thought core.async has 2 thread pools. the pool with 42 + x for c.a/go and the unbounded pool for c.a/thread . I was wrong again.

11:52 justin_smith: mavbozo: right, but I wasn't using thread :P

11:52 mavbozo: but that is the tool that solves my problem, of course

11:54 bluezone: THANKS A LOT GUYS. Now I can't sleep anymore. Every time I close my eyes I see parenthesis all over the place :( Language is too sexy for my eyes

11:57 mavbozo: justin_smith, yeah, c.a/thread doesn't make differences in your mongo case either

11:57 {blake}: bluezone: The real shift comes when you STOP seeing parentheses. Then you'll know you're One Of Us.

11:57 justin_smith: mavbozo: right, well, it makes it slightly less painful but does not solve it

11:59 now I am doing an audit of our usage of core.async, and seriously considering replacing mongo with a table in postgres with a string key and byte-array value, and encoding that byte-array with transit :P

12:36 Glenjamin: justin_smith: i think that's a solid plan: mongo query perf is pretty bad on unindexed keys, so it's not like you can really actually query the json properly

12:37 although new postgres i think has json column, json functions and function indexes

12:53 the_nonameguy: is it possible to write a fn with an example use like this?

12:53 (source-2 clojure.lang.Keyword clojure.lang.IFn)

12:53 which would display the protocols implementation for the given type

12:54 like source does for plain fn-s

13:03 {blake}: How does Clojure not have an .indexOf for vectors?

13:06 justin_smith: ,(.indexOf [:a :b :c] :b) ; {blake}

13:06 clojurebot: 1

13:07 {blake}: justin_smith: That's not Clojure. =P

13:07 justin_smith: {blake}: that's clojure

13:07 gfredericks: weelllll

13:07 ,(.indexOf [1 2 3] 2N)

13:07 clojurebot: 1

13:07 gfredericks: hmm

13:07 {blake}: Heh.

13:08 gfredericks: ,(.indexOf [1N 2N 3N] 2)

13:08 clojurebot: 1

13:08 gfredericks: how does that wark

13:08 justin_smith: gfredericks: equality

13:08 ,(= 1 1N)

13:08 clojurebot: true

13:08 gfredericks: oh I forgot this was clojure.lang code being run

13:08 for some reason

13:08 justin_smith: gfredericks: see, it's clojure

13:08 gfredericks: yeah okay it's all fine

13:09 justin_smith: if it didn't use a .equals or .equiv defined by clojure, then I'd agree it wasn't clojure

13:09 {blake}: justin_smith: It's invoking a Java object method, yes? Wouldn't work in ClojureScript? Might or might not work in .NET?

13:10 justin_smith: {blake}: sure, but that's the case for much of the language

13:10 {blake}: I mean, there's a clojure.string/capitalize, fercryinoutloud.

13:11 So, I'm surprised by the absence of an index-of.

13:11 gfredericks: I think you're supposed to not want to use it

13:11 but I still want to use it sometimes

13:12 {blake}: gfredericks: What, .indexOf? Well, I'm open to alternatives. Given a symbol, I want to cycle to the next item in the collection (with wrapping).

13:12 This is user driven.

13:15 strtok: anyone using the clj-slackbot? i get java.security.AccessControlException when trying.

13:16 gfredericks: {blake}: sometimes there are alternate data structures. like it sounds like you could easily create a map that tells you what the next thing is

13:16 ,(def things '[item1 item2 item32 item5])

13:16 clojurebot: #'sandbox/things

13:17 gfredericks: ,(def next-item (->> things (concat things) (partition 2 1) (take (count things)) (into {})))

13:17 clojurebot: #error {\n :cause "clojure.lang.Symbol cannot be cast to java.util.Map$Entry"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.util.Map$Entry, compiling:(NO_SOURCE_FILE:0:0)"\n :at [clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3661]}\n {:type java.lang.ClassCastException\n :message "clojure...

13:17 {blake}: gfredericks: Yeah. I actually did that the other day. It just seems like more work than should be necessary.

13:17 gfredericks: {blake}: the upside is you don't have to think about indexes

13:17 why the hell didn't my code work

13:17 {blake}: I always have this problem with SQL, too. Sometimes order is significant.

13:18 gfredericks: we're still dealing with ordering

13:18 just not indexes

13:18 ,(def next-item (->> things (concat things) (partition 2 1) (take (count things))))

13:18 clojurebot: #'sandbox/next-item

13:18 gfredericks: ,next-item

13:18 clojurebot: ((item1 item2) (item2 item32) (item32 item5) (item5 item1))

13:18 gfredericks: oh vectors

13:18 thanks conj

13:18 ,(def next-item (->> things (concat things) (partition 2 1) (map vec) (take (count things))))

13:18 clojurebot: #'sandbox/next-item

13:18 gfredericks: ,next-item

13:18 clojurebot: ([item1 item2] [item2 item32] [item32 item5] [item5 item1])

13:18 gfredericks: baaah

13:18 {blake}: lol

13:18 gfredericks: ,(->> things (concat things) (partition 2 1) (map vec) (take (count things)) (into {}))

13:18 clojurebot: {item1 item2, item2 item32, item32 item5, item5 item1}

13:18 {blake}: Friday

13:18 gfredericks: there we go

13:19 so it's easy to make a map like that one, and to do it in a way where you never refer to indexes

13:19 {blake}: gfredericks: Yeah, it's not bad. I'm just not sure I buy this indexes-considered-harmful stuff. =P

13:19 gfredericks: yeah I'm on the fence

13:20 they don't seem necessary for this case though; and my code even handles the cycling in a less special-casey kind of way

13:20 {blake}: It also seems processor intensive. The way I did this--I forget who put this in the chat--but it was with an order function: (zipmap s (range)).

13:21 It's slick but I'm just making a map every time.

13:21 gfredericks: that should be the same amount of work as mine

13:21 mine just makes a map

13:22 {blake}: Right. So why wouldn't I just use a map, other than feeling that a vector should be treatable as a map? I can say nth, after all, so why not itemth?

13:25 mgaare_: ,(zipmap (drop-last things) (drop 1 things))

13:25 clojurebot: {item1 item2, item2 item32, item32 item5}

13:25 mgaare_: oh but you want a cycle

13:29 mgaare: ,(zipmap things (-> things (rest) (vec) (conj (first things)))

13:29 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

13:29 mgaare: doh

13:29 well, that's the idea

13:30 {blake}: mgaare: So, just add it to the back when we run out? Heh.

13:30 TEttinger: ,(nth (cycle things) 15)

13:30 clojurebot: #error {\n :cause "Unable to resolve symbol: things in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: things in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: things in t...

13:31 TEttinger: ,(def things '[item1 item2 item32 item5])

13:31 clojurebot: #'sandbox/things

13:31 TEttinger: ,(nth (cycle things) 15)

13:31 clojurebot: item5

13:31 mgaare: ahhh cycle, of course

13:31 TEttinger: infinite lazy seq

13:31 mgaare: might be a little nicer to use

13:32 ,(zipmap things (rest (cycle things)))

13:32 clojurebot: {item1 item2, item2 item32, item32 item5, item5 item1}

13:33 {blake}: ,things

13:33 clojurebot: [item1 item2 item32 item5]

13:33 kungi: How can I split build configurations for lein cljsbuild in dev and production. Production should be activated when compiling an uberjar.

13:34 mgaare: ah, and just using cycle handles the original request more elegantly too

13:35 Glenjamin: is there anything in core I can use to put vars / locals in a map with keys of the same name?

13:35 (??? name key val) -> {:name name :key key :val val}

13:37 mgaare: I don't think so, but you could do something like #(zipmap (map keyword %) %)

13:43 noncom: justin_smith: oh wow, core async + mongo sabotage

13:43 {blake}: justin_smith: Oh, yeah, did you get that figured out?

13:43 noncom: i even afraid to imagine what you had to go through to find that out...

13:44 {blake}: It was a mix of async and mongo? *gets nervous*

13:45 justin_smith: heh

13:45 noncom: yourkit, it's like magic

13:46 mgaare: I think Glenjamin wants the name of the binding mapped to the bound value - iirc something in flatland/useful does this

13:46 Glenjamin: of course, flatland/useful does everything :)

13:46 justin_smith: Glenjamin: I think this does what you want https://github.com/flatland/useful/blob/develop/src/flatland/useful/map.clj#L9

13:47 Glenjamin: i'm noticing i'm doing this a fair bit when passing context to (ex-info)

13:47 yup, that's the one

13:47 mgaare: mm, I see

13:51 Glenjamin: and is there a variant of (get) which throws on unknown keys?

13:51 TEttinger: justin_smith: dammit yourkit... here I am trying out JVM profilers last updated in 2007

13:52 ,(get {:a 1 :b 2} :a)

13:52 clojurebot: 1

13:52 TEttinger: ,(get {:a 1 :b 2} :c)

13:52 clojurebot: nil

13:52 TEttinger: hm

13:52 nth fails with vectors...

13:52 but get doesn't with maps

13:53 ,(nth [1 2] 3)

13:53 clojurebot: #error {\n :cause nil\n :via\n [{:type java.lang.IndexOutOfBoundsException\n :message nil\n :at [clojure.lang.PersistentVector arrayFor "PersistentVector.java" 157]}]\n :trace\n [[clojure.lang.PersistentVector arrayFor "PersistentVector.java" 157]\n [clojure.lang.PersistentVector nth "PersistentVector.java" 161]\n [clojure.lang.RT nth "RT.java" 846]\n [sandbox$eval73 invokeStatic "NO_SOURCE...

13:53 justin_smith: ,(nth [1 2] 3 :not-found)

13:53 clojurebot: :not-found

13:53 TEttinger: yeah, that's a good example

13:53 bluezone: Theses docs http://clojure-doc.org/ are so much better than the living clojure book

13:53 justin_smith: different defaults, but you can get the same behavior

13:55 Glenjamin: (if (contains? @conf name) (get @conf key-name) (throw (ex-info "Unknown config key" {:name name})))

13:56 justin_smith: (get {:a 0} :b (lazy-seq (throw (Exception. "boom")))) ; works, but is a hack

13:56 Glenjamin: heh

13:57 justin_smith: but the lazy-seq means no throw happens if the key is found

13:57 but also means no exception if you don't use the return value :P

13:59 noncom: justin_smith: hmmm! yourkit... i heard of it.. i think i'll try learning more of it

14:00 maybe it will come to use one day

14:00 for me too

14:03 TEttinger: noncom: if your company is paying for it I would use it like there's no tomorrow

14:04 justin_smith: TEttinger: or start / contribute to a healthy and useful open source project

14:05 TEttinger: I have no idea what yourkit considers useful, haha

14:05 oddcully: justin_smith: why bother, if nomcoms company would pay for tettingers version?

14:05 TEttinger: haha

14:05 right, I mixed up your and I

14:09 justin_smith: TEttinger: sometimes I forget which guy I am too, I get myself mixed up with gfredericks all the time and I'm all like "wait, I thought I was supposed to live in Chicago?"

14:10 TEttinger: I can't remember which time zone the noisesmith is in

14:10 justin_smith: hipster central

14:11 noncom: TEttinger: yeah its probably payed

14:26 phaseNi: cd

14:26 whoops

14:28 bluezone: What's the difference between a keyword and a symbol? A keyword doesn't have to be explicitly defined with def?

14:28 Bronsa: bluezone: a keyword is more like a string than like a symbol

14:29 bluezone: mmm i see

14:29 Bronsa: keywords are self-evaluating

14:29 but like symbols, they have an (optional) namespace and name component

14:29 and like symbols, they are also functions

14:32 TimMc: bluezone: Keywords are generally intended to represent themselves, usually as lookup keys or sometimes as sentinals or out-of-band values.

14:33 bluezone: Symbols are generally intended to be bound to values in a program, or represent them.

14:34 Symbols are most often seen in compilation or related contexts, and keywords are usually seen in data.

14:53 bluezone: Not sure If I grasped it yet, i am missing terminology. But will move on for now, seems to only be used as keys and certain actions (like :as in require)

14:54 https://www.refheap.com/111431 In this example why aren't they forced to (declare do-it) before making the call to (do-it) ?

14:54 The example is under the heading "Layout of functions" here http://clojure-doc.org/articles/tutorials/introduction.html#functions-defining-your-own

14:55 justin_smith: bluezone: certain functions or macros treat keywords specially - because they are looking for that keyword

14:55 bluezone: ah okay

14:55 justin_smith: so it's like a pseudo-syntax

14:57 oddcully: bluezone: this (to me) makes no sense. you can not call (do-it) even if you would declare it

14:57 ,(declare do-it)

14:57 ,(do-it)

14:57 clojurebot: #'sandbox/do-it

14:57 #error {\n :cause "Attempting to call unbound fn: #'sandbox/do-it"\n :via\n [{:type java.lang.IllegalStateException\n :message "Attempting to call unbound fn: #'sandbox/do-it"\n :at [clojure.lang.Var$Unbound throwArity "Var.java" 43]}]\n :trace\n [[clojure.lang.Var$Unbound throwArity "Var.java" 43]\n [clojure.lang.AFn invoke "AFn.java" 28]\n [sandbox$eval47 invokeStatic "NO_SOURCE_FILE" 0]\n...

14:57 bluezone: I think you need to put it in the same line

14:58 ,(declare do-it) (do-it)

14:58 clojurebot: #'sandbox/do-it

14:58 justin_smith: bluezone: no, that just works accidentally

14:58 bluezone: ,(do-it) (declare do-it)

14:58 clojurebot: #error {\n :cause "Attempting to call unbound fn: #'sandbox/do-it"\n :via\n [{:type java.lang.IllegalStateException\n :message "Attempting to call unbound fn: #'sandbox/do-it"\n :at [clojure.lang.Var$Unbound throwArity "Var.java" 43]}]\n :trace\n [[clojure.lang.Var$Unbound throwArity "Var.java" 43]\n [clojure.lang.AFn invoke "AFn.java" 28]\n [sandbox$eval93 invokeStatic "NO_SOURCE_FILE" 0]\n...

14:58 oddcully: no i't does not know, what to run

14:58 justin_smith: bluezone: clearly what they meant in the example is (declare doit) (defn foo [] (doit)) (defn doit [])

14:58 that works

14:59 but what they have on that page is broken

14:59 bluezone: ,(declare do-it) (do-it) ;; <- is that okay?

14:59 clojurebot: #'sandbox/do-it

14:59 oddcully: no

15:00 "one line" does not matter here

15:01 bluezone: ,(declare do-it) (do-it "fanculo"]) (defn do-it [x] (println x))

15:01 clojurebot: #'sandbox/do-it

15:01 justin_smith: bluezone: clojurebot is not a repl, it ignores everything after the first form

15:01 bluezone: o

15:02 justin_smith: ,:foo (/ 1 0) (println "this doesn't happen")

15:02 clojurebot: :foo

15:02 mgaare: evidence: it ignored unmatched ] in (do-it "fanculo"]) ;)

15:02 bluezone: Okay I shall try in repl i suppose

15:03 oddcully: you will get the error with the "unbound fn"

15:03 bluezone: yeah I saw that ^_^

15:03 oddcully: unless you have defined that fn beforehand at any point in your repl

15:03 justin_smith: bluezone: declare is for putting things in function definitions that are not yet defined, but you still need to define the thing before the function is called or you get an error

15:06 bluezone: so you can use (delcare func) (defn test [] (func)) (defn func [] (println "abc")) . But you can't do (delcare func) (func) (defn func [] (println "abc")) ?

15:07 Seems odd to me that you could use the function inside a function definition, but you can't call it if it hasn't been defined above the call

15:08 amalloy: bluezone: forms are evaluated sequentially

15:08 how could (func) be evaluated if you haven't supplied a definition?

15:08 bluezone: yeah the definition is below :( but what's the point of declare then?

15:09 Just so you can use (func) in another function definition before declaring (defn func [] () ) ?

15:09 oddcully: it's a forward declaration

15:10 johannbestowrous: hey guys im working with a coworker to get lein up and running on his computer

15:10 and he's running into an issue similar to this gist https://gist.github.com/brandonbloom/d3598b6f2e4ef493ed56

15:10 bluezone: I blame them for confusing me with their terrible example :)

15:10 johannbestowrous: anyone have any familiarity with this issue?

15:11 amalloy: johannbestowrous: looks to me like his project.clj has junk in it?

15:11 maybe

15:11 johannbestowrous: hey amalloy--no project.clj, literally just running lein repl

15:12 bluezone: maybe your lein is 32 bit? ^_^ random guess

15:12 oddcully: bluezone: ignore that example. it is wrong and makes no sense

15:13 amalloy: johannbestowrous: honestly that's a pretty weird error to me. maybe upgrade lein? like i got 2.5.2 months ago so i'm a little confused why someone who's starting out is on 2.5.1

15:13 oddcully: johannbestowrous: maybe bork in ~/.lein/profiles.clj?

15:13 johannbestowrous: good call

15:14 oddcully: also isn't that java there ancient?

15:14 erm sorry... that is not _your_ error

15:15 johannbestowrous: oddcully

15:15 excellent excellent excellent

15:15 i owe you a beer :)

15:15 fixed his profiles.clj :)

15:16 bluezone: I e-mailed the docs author :)

15:17 oddcully: johannbestowrous: cheers!

15:21 johannbestowrous: hell everyone who offered help gets a beer

15:26 PMunch: Hi I want to use map on a set of data (read from a file) with a function that takes in two arguments (one which is the element, the other which is constant). What I've done is to create an anonymous function #(func % 10) which I try to use in the map but I've getting an error Wrong number of args. What gives?

15:27 TEttinger: PMunch: that fn always takes one arg

15:27 the #() I mean

15:28 PMunch: TEttinger, yes and that's all it gets from map isn't it?

15:28 http://pastebin.com/7uEhdBrN << complete code

15:28 TEttinger: thanks

15:30 PMunch: TEttinger, keep in mind I'm fairly new to Clojure so that code might be quite horrible..

15:30 TEttinger: no no, it actually looks fine

15:30 so stack-hash takes two args?

15:32 PMunch, that really doesn't look like "fairly new to clojure" style code. my first clojure program used ref everywhere

15:33 xeqi: and there isn't any nested defns

15:33 PMunch: Haha, I took some time with it the first time around. Used it for a school project to write a distributed hash map running on a cluster, but that's the only time I've used it

15:34 TEttinger: nice

15:34 so what does stack-hash's arglist look like?

15:34 PMunch: [in size]

15:34 TEttinger: and that isn't in another set of square brackets, right?

15:35 PMunch: It's basically a function that hashes the input and places in a bucket within size

15:35 No

15:35 TEttinger: ok

15:35 PMunch: http://pastebin.com/ZU7xHY1T

15:36 There's the stack-hash function (poor name I know, it's a hashing algorithm I got from stackexchange..)

15:36 TEttinger: so what error does it throw, and does it have a meaningful line number?

15:36 xeqi: PMunch: (stack-hash (str first-four)) only recurses with one argument

15:37 PMunch: Shit, just realised -_-

15:37 Sorry, my bad. I've been struggling for so long to get the file reading right I just assumed the error was there..

15:38 And sorry if swearing isn't allowed..

15:38 TEttinger: no worries

15:38 you may want to make that recur like you do earlier

15:39 PMunch: The whole function? What would the benefit be over recursing like I do now? Or is it just idiomatic?

15:40 Hmm, I guess I could let n and mask be the same by doing it that way. No need to recompute them..

15:40 justin_smith: PMunch: (fn foo [] (foo)) uses stack, (fn foo [] (recur)) does not

15:40 timvisher: is there a way to take an arbitrary clojure structure that i can quote and pretty print it?

15:40 it has 'seqs' embedded in it

15:40 justin_smith: timvisher: I assume there is a problem with clojure.pprint/pprint ?

15:40 timvisher: it's a logged ring response from ring.middleware.logger if you're familiar with it

15:41 PMunch: justin_smith, really? I thought it did and that recur was simply a different way of doing it. Neat!

15:41 justin_smith: PMunch: no automatic TCO in clojure, only explicit

15:42 timvisher: justin_smith: oh duh. i didn't think to pass the quoted form to pprint. i kept trying to pass the unquoted form. :facepalm:

15:42 TEttinger: ,(map seq [1 2 3 4] [10 20 30 40])

15:42 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core/seq--4116>

15:42 TEttinger: ,(map list [1 2 3 4] [10 20 30 40])

15:42 clojurebot: ((1 10) (2 20) (3 30) (4 40))

15:42 TEttinger: ,(str (map list [1 2 3 4] [10 20 30 40]))

15:42 clojurebot: "clojure.lang.LazySeq@1e56653"

15:42 TEttinger: ,(pr-str (map list [1 2 3 4] [10 20 30 40]))

15:42 clojurebot: "((1 10) (2 20) (3 30) (4 40))"

15:43 justin_smith: yeah, pr-str helps, but pprint already does the equivalent of pr-str, recursively

15:43 TEttinger: ah

15:43 that does appear to recurse by two levels though

15:44 ,(pr-str (map #(seq %&) (map list [1 2 3 4] [10 20 30 40]) (map list [1 2 3 4] [10 20 30 40])))

15:44 clojurebot: "(((1 10) (1 10)) ((2 20) (2 20)) ((3 30) (3 30)) ((4 40) (4 40)))"

15:45 drorbemet: Hi, what's an easy way to eval a string of clojure code from emacs lisp when using cider?

15:45 justin_smith: another underappreciated gem is clojure.pprint/print-table

15:45 (for lists of hash-maps)

15:46 s/lists/sequable

15:46 mikerod_: @drorbemet cider-read-and-eval

15:46 specifically

15:46 M-x cider-read-and-eval

15:47 if you want to do it in minibuffer that is

15:47 or perhaps you wanted to do it not in minibuffer?

15:59 drorbemet: mikerod_: yes, I want to pass clojure code directly to cider-read-and-eval. I just tried that without success. Now I am looking at cider-eval-region trying to learn from it (cider-interactive-eval nil nil (list start end)) ... but I don't know jet how to pass a string instead of a region.

16:00 mikerod: @drorbemet to me it looks like most of the API there is tailored towards the interactive eval

16:00 drorbemet: mikerod_: So I am missing cider-eval-string I guess.

16:00 mikerod: that is just my preliminary thoughts though

16:01 justin_smith: drorbemet: iirc there is a function with "send" in the name that takes a string...

16:02 drorbemet: mikerod: yes to me it looks like that too ... maybe I sould send an issue to the cider developers

16:02 justin_smith: oh, let me check

16:02 mikerod: you could probably just call the nrepl-client stuff directly too

16:02 that may be undesirable

16:03 drorbemet: justin_smith: there are a lot of functions with "send" in their names

16:05 justin_smith: yeah, sorry I can't remember more specifically

16:05 drorbemet: mikerod: whell I am starting a cider repl via cider-jack-in and then I want to eval some code that I don't want to put into a file ... maybe should I just give up and put it in a file

16:06 mikerod: drorbemet: yeah, there are ways to implement it yourself, but not sure how to reuse the most out of cider for it

16:07 justin_smith: drorbemet: cider-eval-defun-at-point

16:07 drorbemet: mikerod: I'll ask the cider people, thanks for discussing the issue though, have a nice day

16:08 justin_smith: drorbemet: oh, you want to type the code into the minibuffer?

16:08 drorbemet: in that case cider-read-and-eval

16:09 drorbemet: justin_smith: cider-read-and-eval and cider-eval-defun-at-point do not take a string as an argument, I want to call elisp code from the command line

16:10 justin_smith: drorbemet: ahh, right - look at the functions in cider-client.el

16:10 drorbemet: also, it's a common enough thing in elisp code to create a "temp buffer" that the user can't see, and put a string in it, for functions that want a buffer

16:11 mikerod: I don't even understand how cider-read-and-eval can take forms that are not readable in elisp

16:11 magic

16:11 example

16:11 #{1}

16:11 drorbemet: justin_smith: ah, ok thanks for that hint. I found that to cumbersome at first, but right in emacs thats the way to go.

16:11 justin_smith: mikerod: because the minibuffer is not an elisp repl

16:12 mikerod: I was trying to see if you could just break out the read-from-string part and than pass that form through to what wants a form

16:12 oh

16:12 justin_smith: mikerod: you can make an elisp repl with ielm, it's handy for when you want to debug elisp code

16:12 M-x ielm that is

16:13 mikerod: justin_smith: this is interesting

16:13 I'll have to look at this some more

16:13 drorbemet: mikerod: cider-eval-region gets close I think

16:16 justin_smith: drorbemet: there's also this, plus a function that handles the result as a callback https://github.com/clojure-emacs/cider/blob/master/cider-client.el#L451

16:17 who knows what the data you get back is, but it shouldn't be too hard to experiment

16:17 oh, and even simpler, the sync version https://github.com/clojure-emacs/cider/blob/master/cider-client.el#L463 should do exactly what you expect

16:24 drorbemet: justin_smith: I tested those, now I figured that I want to see the output in the cider repl buffer. Both functions don't do that. I will return to cider-load-file I guess.

16:26 justin_smith: drorbemet: a callback can totally do that

16:28 drorbemet: justin_smith: ok, but then I have a new dependency in my emacs config ... which I was trying to avoind

16:29 justin_smith: It's ok I will bend around it :-)

16:33 PMunch: Hmm I'm having some trouble porting this hashing algorithm from Python. I would say they are the same but they don't give the same results.. Clojure version: http://pastebin.com/hzgQWTXS

16:33 Python version: http://pastebin.com/utAnsngp

16:34 I've tested that the last_four thing gives the same numbers and that the n is the same for both..

16:34 But the Clojure version seems to put a lot more (about 3x intended) into one bucket..

16:41 TEttinger: PMunch: I suspect it may have to do with the behavior of math in clojure having some different defaults

16:43 PMunch: TEttinger, could be..

16:44 justin_smith: PMunch: what's up with stack_hash, which full_hash calls in the python version?

16:46 PMunch: one thing to check out is that clojure assumes vals are 64 bits (long not int, double not float)

16:48 PMunch: justin_smith, It does?

16:48 justin_smith: ,(type (+ Integer/MAX_VALUE 1)) ; PMunch - also, auto-promotes

16:48 clojurebot: java.lang.Long

16:48 justin_smith: PMunch: yes

16:48 PMunch: it strongly prefers 64 bit numbers

16:48 ,(type 1)

16:48 clojurebot: java.lang.Long

16:49 TEttinger: ,(Long/highestOneBit 5)

16:49 clojurebot: 4

16:50 TEttinger: ,(dec (* 2 (Long/highestOneBit 5)))

16:50 justin_smith: TEttinger: oh, that would simplify his code wouldn't it

16:50 clojurebot: 7

16:50 TEttinger: yeah I use it or methods like it a fair amount in java

16:50 PMunch: Hmm, I think one of the reasons might be that Python reads in newlines as part of a line..

16:51 justin_smith: oh yeah, line-seq doesn't give you the newlines either

16:51 TEttinger: ,(Long/numberOfTrailingZeros (Long/highestOneBit 5))

16:51 clojurebot: 2

16:51 TEttinger: ,(inc (Long/numberOfTrailingZeros (Long/highestOneBit 5)))

16:51 clojurebot: 3

16:52 TEttinger: ,(Math/ceil (/ (Math/log 5) (Math/log 2)))

16:52 clojurebot: 3.0

16:52 TEttinger: ah, that might be another gotcha

16:52 ceil returns a double

16:52 it doesn't in all languages

16:52 justin_smith: TEttinger: but it's only used in the pow call right?

16:53 TEttinger: yeah, which is where...

16:53 PMunch: Hmm, I stripped the newline in python and while I get different results they are still better distributed..

16:53 TEttinger: ,(int (- (Math/pow 2 (Math/ceil (/ (Math/log 5) (Math/log 2)))) 1))

16:53 clojurebot: 7

16:54 TEttinger: ,(dec (* 2 (Long/highestOneBit 5)))

16:54 clojurebot: 7

16:54 TEttinger: I think this might be a bit simpler/mor efficient

16:55 also, PMunch, what's the difference between stack_hash and full_hash in the python?

16:56 PMunch: It's basically the same

16:56 You can change that line to: return full_hash(str(Hv),N)

16:56 And it does the exact same thing

16:57 TEttinger: but full_hash takes 3 args

16:57 assuming there's an 'n' in there somewhere

16:58 and I realy have no idea what this does: first_four = int(to2sCompStr(Hv,64)[64-n:],2)

17:00 PMunch: It selects the 4 least significant bits of Hv

17:02 Okay, I have now found one word that classifies differently "you" over 30 buckets. It starts of equal, both evaluating to 31, then on the second go clojure gives hash 1630 while Python gives hash 1449834469

17:03 TEttinger: ,(reduce #(mod (+ (* %1 31) (int %2)) 2147483647) 0 "alpha") ; Hv = (Hv*31+ord(c))%2147483647

17:03 clojurebot: 92909918

17:03 TEttinger: ,(reduce #(mod (+ (* %1 31) (int %2)) 2147483647) 0 "you") ; Hv = (Hv*31+ord(c))%2147483647

17:03 clojurebot: 119839

17:03 TEttinger: ,(reduce #(mod (+ (unchecked-multiply-int %1 31) (int %2)) 2147483647) 0 "you") ; Hv = (Hv*31+ord(c))%2147483647

17:03 clojurebot: 119839

17:04 PMunch: Yea, that's the first round

17:04 The four least significant bits makes that number 31

17:04 ,(reduce #(mod (+ (unchecked-multiply-int %1 31) (int %2)) 2147483647) 0 "31") ; Hv = (Hv*31+ord(c))%2147483647

17:04 clojurebot: 1630

17:04 PMunch: Python gives 1449834469

17:05 TEttinger: wait wait

17:05 "31")

17:06 are you feeding the number back as a string?

17:06 justin_smith: TEttinger: yup - it's in the code

17:06 TEttinger: also 31 is...

17:06 PMunch: TEttinger, yes that's because I used a hashing algorithm for strings..

17:06 TEttinger: ,(Integer/toBinaryString 31)

17:06 clojurebot: "11111"

17:06 PMunch: I should probably change that

17:06 TEttinger: 31 is 5 bits all 1

17:06 PMunch: Yes

17:07 Oh sorry, I was working with 4 bits before. I meant 5 least significant bits

17:07 TEttinger: oh ok

17:07 PMunch: So it seems like it is actually Python which is doing something weird. But somehow it ends up more right..

17:08 justin_smith: which "unchecked-multiply-int" ?

17:08 PMunch: Oooooh

17:08 Found the bug..

17:08 TEttinger: justin_smith: hm?

17:09 PMunch: In clojure I do (recur (str first-four)), while in Python it is full_hash(str(Hv),N)

17:09 justin_smith: TEttinger: sorry, meant "why"

17:10 TEttinger: I thought we were expecting 32 bit precision

17:10 PMunch: So it wasn't related to Clojure at all. Sorry guys for wasting your time

17:10 TEttinger: to match python

17:10 no prob

17:11 PMunch: But you had some good ideas on improving the bit checking algorithm so it wasn't all for nothing

17:17 TEttinger: ,(defn stack-hash [in size] (let [mask (* 31 (Long/highestOneBit size)) Hv (reduce #(mod (+ (unchecked-multiply %1 31) (int %2)) 2147483647) 0 in) first-five (bit-and Hv mask)] (if (< first-five size) first-five (recur (str Hv) size))))

17:17 clojurebot: #'sandbox/stack-hash

17:17 TEttinger: ,(stack-hash "you")

17:17 clojurebot: #error {\n :cause "Wrong number of args (1) passed to: sandbox/stack-hash"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: sandbox/stack-hash"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 32]\n [sandbox$eval52 invokeStatic "NO_SOURCE_FILE" 0]\n ...

17:17 TEttinger: ,(stack-hash "you" 5)

17:17 clojurebot: 4

17:17 TEttinger: I don't know what size should be

17:17 ,(stack-hash "you" 31)

17:17 clojurebot: 16

17:19 TEttinger: ,(defn stack-hash [in size] (let [mask (* 31 (Long/LowestOneBit size)) Hv (reduce #(mod (+ (unchecked-multiply %1 31) (int %2)) 2147483647) 0 in) first-five (bit-and Hv mask)] (if (< first-five size) first-five (recur (str Hv) size))))

17:19 clojurebot: #error {\n :cause "No matching method: LowestOneBit"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: No matching method: LowestOneBit, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.IllegalArgumentException\n :message "No matching method: LowestOneBit"\n :at [clojure...

17:19 TEttinger: ,(defn stack-hash [in size] (let [mask (* 31 (Long/lowestOneBit size)) Hv (reduce #(mod (+ (unchecked-multiply %1 31) (int %2)) 2147483647) 0 in) first-five (bit-and Hv mask)] (if (< first-five size) first-five (recur (str Hv) size))))

17:19 clojurebot: #'sandbox/stack-hash

17:19 TEttinger: ,(stack-hash "you" 31)

17:19 clojurebot: 5

17:19 TEttinger: hm

17:20 ,(stack-hash "you" 1024)

17:20 clojurebot: 0

18:01 Trioxin: question: Let's say I want to be able to make use of multiple cores and the full power of GPUs, is OpenCL the best route? This would be for machine learning algorithms.

18:02 OpenCL seems to be the easiest route. That's what i mean by best (Most portable across all architectures)

18:03 Or would it be best to just use the JVM for the CPU cores and openGL for GPU processing?

18:03 but then again I'm using two different things at that point for 1 algorithm whereas openCL...

18:05 rhg135: u8n-o oh7o .7ohq. cy6 cq,qc"

18:05 err, wrong dhan

19:16 domokato: if two threads force a delay at the same time, is the delay body invoked twice?

19:16 justin_smith: domokato: you could try, but my strong guess is no

19:19 domokato: looks good to me https://www.refheap.com/111441

19:21 domokato: thanks!

19:21 where is the parallelization in your code, though?

19:21 justin_smith: the futures

19:22 domokato: oops

19:22 missed those

19:23 justin_smith: you can try the same function calls, but eg. add (Thread/sleep (rand-int 300)) into the doseq before the @d

19:24 I am not sure where sleeps would maximize the collission possibility actually, now that I think about it - maybe (delay (Thread/sleep (rand-int 300)) (swap! undelay inc))

19:29 McDougal: justin_smith: Are you using any external libs to beef up security in Caribou?

19:30 justin_smith: sure, bcrypt

19:30 (for one)

19:31 McDougal: How about csrf?

19:32 justin_smith: no, that one would be a good reason to bring in friend or buddy yourself

19:32 McDougal: Gotcha, am using Buddy

19:32 And yesql

19:47 TEttinger: domokato: futures are awesome, especially for the kind of thing you're making

19:48 domokato: TEttinger: yeah, i'm using them in a few places

19:48 TEttinger: in a game I partly made, that was 100% clojure, I would generate a level and do some expensive calcs on it before the player reached it, in another thread due to futures

19:49 I'm currently making that approach easy enough to do for java devs with my current lib

19:49 (it would be easier in clojure)

19:53 domokato: nice

19:53 i'm using them for my ai calculations

19:53 for each agent

19:58 Trioxin: domokato, Tettinger, Have you guys used OpenCL? I'm wanting to do machine learning calculations with it.

19:59 TEttinger: I wanted to at one point, but the lib I'm making has android as a target. it's crazy how much google wants to keep openCL off of phones

20:00 Trioxin: it's true that a good GPU is extremely powerful at certain tasks

20:00 Trioxin: Tettinger, a google search is showing results for doing it on android

20:00 TEttinger: not officially. look up nexus opencl

20:00 Trioxin: tettinger, well I want to use both cpu cores and gpu and would rather use 1 thing to do it

20:01 goal would be to deploy to all desktop and mobile platforms using the JVM and cordova

20:01 TEttinger: http://streamcomputing.eu/blog/2013-08-01/google-blocked-opencl-on-android-4-3/

20:02 if you can find a way to use cpu and gpu on both desktop and mobile platforms, will you tell me please?

20:03 Trioxin: so this is just for nexus and they've blocked it in favor of some other thing

20:04 renderscript

20:04 opencl seems like a no brainer. wtf

20:04 and i don't think the current version is in cuda

20:04 but 1. something

20:08 doesn't sounds like fun to have to use GL along with something else for CPU cores to perform the same computations

20:08 TEttinger: Trioxin: there's a hare-brained set of excuses in here https://code.google.com/p/android/issues/detail?id=36361

20:10 Trioxin: tettinger, "If you need "maximum control and speed", you should probably be pursuing custom hardware/software for your use-case."

20:10 like that?

20:10 loll

20:11 makes no sense

20:11 and fragmentation. isn't that sort of a principal of a linux-based OS?

20:12 TEttinger: yeah, their solution is just going to cause fragmentation

20:12 if you have Mali or certain other GPUs, you can use OpenCL

20:12 if you don't, you can't

20:13 Trioxin: and the solution then is to use renderscript? or GL?

20:13 on mobile are the cpu and gpu cores separate?

20:25 TEttinger: Trioxin: man... I haven't found a solution that's very good. there's the old way of GPGPU stuff using pixel shaders to do calculations

20:32 eseg: Hey everyone, how can I destructure a vector into parts while still binding a name to the whole data structure, like as patterns in haskell?

20:37 Frozenlock: ,(let [[a b :as v] [1 2 3 4 5]] {:a a :v v})

20:37 clojurebot: {:a 1, :v [1 2 3 4 5]}

20:38 Frozenlock: destructuring tutorial https://gist.github.com/john2x/e1dca953548bfdfb9844

20:39 eseg: thanks guys

22:14 Trioxin: tettinger, meh. but I guess on desktop and server it should be okay with CL? maybe? except nvidia doesn't support latest versions?

22:22 TEttinger: OpenCL should be perfect for desktop

22:22 it will be supported on windows, mac, linux, with intel, AMD, or NVIDIA GPUs

22:23 justin_smith: TEttinger: have you tried using jocl from clojure?

22:25 TEttinger: no

22:25 Trioxin: tettinger, I think not the current version on nvidia though due to them wanting to promote cuda?

22:25 TEttinger: CUDA is technically a better choice if you know what hardware you're running on

22:25 but you don't know that if distributing an app

22:26 Trioxin: says nvidia supports 1.2

22:26 cl 1.22

22:26 1.2*

22:27 the point for me is that if I'm computing something with openCL I don't have to write any extra code for the CPU than the GPU right?

22:28 other than maybe some settings but don't have to modify the code for the computation?

22:43 TEttinger: I think so yeah

23:02 bluezone: Broadcasting my failures. Can't figure out a null pointer exception -.- https://www.livecoding.tv/bluezone/

23:02 You are welcome to make fun of me

23:17 Frozenlock: Nice

23:17 With music!

23:18 bluezone: ^_^

23:21 justin_smith: bluezone: eventually, first sequ is nil

23:21 bluezone: yeah I tried to avoid that in the and statement hmm

23:21 justin_smith: ,(odd? nil)

23:21 clojurebot: #error {\n :cause "Argument must be an integer: "\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Argument must be an integer: "\n :at [clojure.core$even_QMARK_ invokeStatic "core.clj" 1359]}]\n :trace\n [[clojure.core$even_QMARK_ invokeStatic "core.clj" 1359]\n [clojure.core$odd_QMARK_ invokeStatic "core.clj" 1362]\n [clojure.core$odd_QMARK_ invoke "core.clj" -1]\n [sandbox...

23:22 Frozenlock: bluezone: Montréal?

23:22 justin_smith: (mod nil 2)

23:22 bluezone: Frozenlock: Yeah ^_^

23:22 justin_smith: ,(mod nil 2) ; this is your error, bluezone

23:22 clojurebot: #error {\n :cause nil\n :via\n [{:type java.lang.NullPointerException\n :message nil\n :at [clojure.lang.Numbers ops "Numbers.java" 1013]}]\n :trace\n [[clojure.lang.Numbers ops "Numbers.java" 1013]\n [clojure.lang.Numbers remainder "Numbers.java" 173]\n [clojure.core$mod invokeStatic "core.clj" 3448]\n [clojure.core$mod invoke "core.clj" -1]\n [sandbox$eval49 invokeStatic "NO_SOURCE_FILE"...

23:22 Frozenlock: bluezone: Sherbrooke :-D

23:22 * bluezone giggles

23:23 justin_smith: now you have an infinite loop I think

23:24 bluezone: yeah hmm

23:24 justin_smith: you know how to fix that though I am sure

23:28 bluezone: can't believe it's taking me this long lol

23:28 justin_smith: notice that all those prints have your answer in them

23:28 why didn't it exit?

23:29 ,(rest ())

23:29 clojurebot: ()

23:31 justin_smith: bluezone: or more to the point, how do you make it stop when you have the answer?

23:31 bluezone: hmmm

23:32 something is not right here ^_^

23:32 It needs to stop when sequ is empty

23:32 justin_smith: bluezone: so, don't you need another if to see if you are done?

23:37 * bluezone is slow in the head

23:37 justin_smith: bluezone: very close

23:37 bluezone: check your if scope...

23:38 bluezone: Oh my god :D

23:39 this takes some getting used to I guess :) Thanks

23:40 Not sure why the and statement wasn't working there mhmm

23:40 Trioxin: maybe I'll just take the easy way out and use a node opencl implementation

23:40 and a webkit frontend

23:41 TEttinger: Trioxin: that wouldn't be much help if there's no OpenCL drivers on a phone

23:41 justin_smith: bluezone: you need three conditions!

23:41 Trioxin: didn't mean for phone

23:41 TEttinger: oh ok

23:41 you mentioned cordova at one point

23:41 justin_smith: one if can't do it

23:41 Trioxin: yeah I suppose I'd have to port to their crap

23:41 TEttinger: renderscript, le ugh

23:42 Trioxin: for mobile

23:42 yea

23:42 bluezone: justin_smith: I thought I only had two :O

23:42 justin_smith: bluezone: even (keep going) odd (keep and keep going) empty (done)

23:42 so you need at least two ifs

23:42 or a cond

23:46 bluezone: Not sure hmm

23:47 justin_smith: bluezone: there are tree conditions to check for

23:47 right?

23:47 clojurebot: right is not wrong

23:47 justin_smith: even, odd, done

23:47 bluezone: yeah but even and odd is checked by 1 form

23:47 justin_smith: OK, so you need how many ifs?

23:48 also you don't need that (do ...)

23:48 bluezone: I would need 2 ifs, but why can't I put the conditions together with (and x x )

23:48 and then just use 1 if

23:48 justin_smith: bluezone: because that's still only one condition with two branches

23:48 you need three branches

23:48 bluezone: urghh I'm so stupid :D

23:49 I see it

23:49 Just not use to reasoning in this lisp style

23:49 justin_smith: while you are at it, look at the doc for cond on clojuredocs

23:51 bluezone: sorry, I might have jumped too far ahead with cond - cond replaces nested ifs

23:51 so you use it instead of if

23:55 thomsey: Hey friends, I'm messing around with seesaw & nothing I do will make (timer) fire it's callback. Has the API changed since the docs were updated last?

23:57 TEttinger: thomsey, what does your callback look like?

23:57 thomsey: (fn [e] (print "works"))

23:58 bluezone: REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEKT

23:58 thomsey: bcuz I didn't (fn [e] (print "works") e)

23:58 ?

23:58 bluezone: justin_smith: Thanks so much :)

23:59 justin_smith: bluezone: np - one other small thing - you can define multiple arities for one function (and that way combine odd-num-seq and _odd-num-seq into one definition)

Logging service provided by n01se.net